@@ -20,25 +20,21 @@ package containerd
2020
2121import (
2222 "context"
23- "encoding/json"
2423 "fmt"
2524 "os"
2625 "path/filepath"
2726 "syscall"
2827
29- "github.com/containerd/containerd/api/types"
3028 "github.com/containerd/containerd/containers"
3129 "github.com/containerd/containerd/content"
3230 "github.com/containerd/containerd/errdefs"
3331 "github.com/containerd/containerd/images"
3432 "github.com/containerd/containerd/mount"
3533 "github.com/containerd/containerd/platforms"
36- "github.com/containerd/containerd/runtime/linux/runctypes"
3734 "github.com/gogo/protobuf/proto"
3835 protobuf "github.com/gogo/protobuf/types"
3936 "github.com/opencontainers/image-spec/identity"
4037 "github.com/opencontainers/image-spec/specs-go/v1"
41- ocispec "github.com/opencontainers/image-spec/specs-go/v1"
4238 "github.com/pkg/errors"
4339)
4440
@@ -105,44 +101,6 @@ func WithCheckpoint(im Image, snapshotKey string) NewContainerOpts {
105101 }
106102}
107103
108- // WithTaskCheckpoint allows a task to be created with live runtime and memory data from a
109- // previous checkpoint. Additional software such as CRIU may be required to
110- // restore a task from a checkpoint
111- func WithTaskCheckpoint (im Image ) NewTaskOpts {
112- return func (ctx context.Context , c * Client , info * TaskInfo ) error {
113- desc := im .Target ()
114- id := desc .Digest
115- index , err := decodeIndex (ctx , c .ContentStore (), desc )
116- if err != nil {
117- return err
118- }
119- for _ , m := range index .Manifests {
120- if m .MediaType == images .MediaTypeContainerd1Checkpoint {
121- info .Checkpoint = & types.Descriptor {
122- MediaType : m .MediaType ,
123- Size_ : m .Size ,
124- Digest : m .Digest ,
125- }
126- return nil
127- }
128- }
129- return fmt .Errorf ("checkpoint not found in index %s" , id )
130- }
131- }
132-
133- func decodeIndex (ctx context.Context , store content.Provider , desc ocispec.Descriptor ) (* v1.Index , error ) {
134- var index v1.Index
135- p , err := content .ReadBlob (ctx , store , desc )
136- if err != nil {
137- return nil , err
138- }
139- if err := json .Unmarshal (p , & index ); err != nil {
140- return nil , err
141- }
142-
143- return & index , nil
144- }
145-
146104// WithRemappedSnapshot creates a new snapshot and remaps the uid/gid for the
147105// filesystem to be used by a container with user namespaces
148106func WithRemappedSnapshot (id string , i Image , uid , gid uint32 ) NewContainerOpts {
@@ -221,19 +179,3 @@ func incrementFS(root string, uidInc, gidInc uint32) filepath.WalkFunc {
221179 return os .Lchown (path , u , g )
222180 }
223181}
224-
225- // WithNoPivotRoot instructs the runtime not to you pivot_root
226- func WithNoPivotRoot (_ context.Context , _ * Client , info * TaskInfo ) error {
227- if info .Options == nil {
228- info .Options = & runctypes.CreateOptions {
229- NoPivotRoot : true ,
230- }
231- return nil
232- }
233- copts , ok := info .Options .(* runctypes.CreateOptions )
234- if ! ok {
235- return errors .New ("invalid options type, expected runctypes.CreateOptions" )
236- }
237- copts .NoPivotRoot = true
238- return nil
239- }
0 commit comments