WithTaskCheckpoint allows a task to be created with live runtime and memory data from a previous checkpoint. Additional software such as CRIU may be required to restore a task from a checkpoint
(im Image)
| 72 | // previous checkpoint. Additional software such as CRIU may be required to |
| 73 | // restore a task from a checkpoint |
| 74 | func WithTaskCheckpoint(im Image) NewTaskOpts { |
| 75 | return func(ctx context.Context, c *Client, info *TaskInfo) error { |
| 76 | desc := im.Target() |
| 77 | id := desc.Digest |
| 78 | index, err := decodeIndex(ctx, c.ContentStore(), desc) |
| 79 | if err != nil { |
| 80 | return err |
| 81 | } |
| 82 | for _, m := range index.Manifests { |
| 83 | if m.MediaType == images.MediaTypeContainerd1Checkpoint { |
| 84 | info.Checkpoint = &types.Descriptor{ |
| 85 | MediaType: m.MediaType, |
| 86 | Size: m.Size, |
| 87 | Digest: m.Digest.String(), |
| 88 | Annotations: m.Annotations, |
| 89 | } |
| 90 | return nil |
| 91 | } |
| 92 | } |
| 93 | return fmt.Errorf("checkpoint not found in index %s", id) |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | // WithCheckpointName sets the image name for the checkpoint |
| 98 | func WithCheckpointName(name string) CheckpointTaskOpts { |
searching dependent graphs…