MCPcopy
hub / github.com/containerd/containerd / WithCheckpointTask

Function WithCheckpointTask

client/container_checkpoint_opts.go:56–94  ·  view source on GitHub ↗

WithCheckpointTask includes the running task

(ctx context.Context, client *Client, c *containers.Container, index *imagespec.Index, copts *options.CheckpointOptions)

Source from the content-addressed store, hash-verified

54
55// WithCheckpointTask includes the running task
56func WithCheckpointTask(ctx context.Context, client *Client, c *containers.Container, index *imagespec.Index, copts *options.CheckpointOptions) error {
57 opt, err := typeurl.MarshalAnyToProto(copts)
58 if err != nil {
59 return nil
60 }
61 task, err := client.TaskService().Checkpoint(ctx, &tasks.CheckpointTaskRequest{
62 ContainerID: c.ID,
63 Options: opt,
64 })
65 if err != nil {
66 return err
67 }
68 for _, d := range task.Descriptors {
69 platformSpec := platforms.DefaultSpec()
70 index.Manifests = append(index.Manifests, imagespec.Descriptor{
71 MediaType: d.MediaType,
72 Size: d.Size,
73 Digest: digest.Digest(d.Digest),
74 Platform: &platformSpec,
75 Annotations: d.Annotations,
76 })
77 }
78 // save copts
79 data, err := proto.Marshal(opt)
80 if err != nil {
81 return err
82 }
83 r := bytes.NewReader(data)
84 desc, err := writeContent(ctx, client.ContentStore(), images.MediaTypeContainerd1CheckpointOptions, c.ID+"-checkpoint-options", r)
85 if err != nil {
86 return err
87 }
88 desc.Platform = &imagespec.Platform{
89 OS: runtime.GOOS,
90 Architecture: runtime.GOARCH,
91 }
92 index.Manifests = append(index.Manifests, desc)
93 return nil
94}
95
96// WithCheckpointRuntime includes the container runtime info
97func WithCheckpointRuntime(ctx context.Context, client *Client, c *containers.Container, index *imagespec.Index, copts *options.CheckpointOptions) error {

Callers

nothing calls this directly

Calls 6

MarshalFunction · 0.92
writeContentFunction · 0.85
TaskServiceMethod · 0.80
CheckpointMethod · 0.65
DigestMethod · 0.65
ContentStoreMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…