MCPcopy
hub / github.com/containerd/containerd / WithRestoreRuntime

Function WithRestoreRuntime

client/container_restore_opts.go:77–109  ·  view source on GitHub ↗

WithRestoreRuntime restores the runtime for the container

(ctx context.Context, id string, client *Client, checkpoint Image, index *imagespec.Index)

Source from the content-addressed store, hash-verified

75
76// WithRestoreRuntime restores the runtime for the container
77func WithRestoreRuntime(ctx context.Context, id string, client *Client, checkpoint Image, index *imagespec.Index) NewContainerOpts {
78 return func(ctx context.Context, client *Client, c *containers.Container) error {
79 name, ok := index.Annotations[checkpointRuntimeNameLabel]
80 if !ok {
81 return ErrRuntimeNameNotFoundInIndex
82 }
83
84 // restore options if present
85 m, err := GetIndexByMediaType(index, images.MediaTypeContainerd1CheckpointRuntimeOptions)
86 if err != nil {
87 if err != ErrMediaTypeNotFound {
88 return err
89 }
90 }
91 var options ptypes.Any
92 if m != nil {
93 store := client.ContentStore()
94 data, err := content.ReadBlob(ctx, store, *m)
95 if err != nil {
96 return fmt.Errorf("unable to read checkpoint runtime: %w", err)
97 }
98 if err := proto.Unmarshal(data, &options); err != nil {
99 return err
100 }
101 }
102
103 c.Runtime = containers.RuntimeInfo{
104 Name: name,
105 Options: &options,
106 }
107 return nil
108 }
109}
110
111// WithRestoreSpec restores the spec from the checkpoint for the container
112func WithRestoreSpec(ctx context.Context, id string, client *Client, checkpoint Image, index *imagespec.Index) NewContainerOpts {

Callers

nothing calls this directly

Calls 4

ReadBlobFunction · 0.92
UnmarshalFunction · 0.92
GetIndexByMediaTypeFunction · 0.85
ContentStoreMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…