Merge pull request #4630 from dcantah/pass-snapshotter-opt
Cri - Pass snapshotter labels into customopts.WithNewSnapshot
This commit is contained in:
commit
9b70de01d6
@ -27,14 +27,15 @@ import (
|
|||||||
"github.com/containerd/containerd/errdefs"
|
"github.com/containerd/containerd/errdefs"
|
||||||
"github.com/containerd/containerd/log"
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/containerd/containerd/mount"
|
"github.com/containerd/containerd/mount"
|
||||||
|
"github.com/containerd/containerd/snapshots"
|
||||||
"github.com/containerd/continuity/fs"
|
"github.com/containerd/continuity/fs"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
// WithNewSnapshot wraps `containerd.WithNewSnapshot` so that if creating the
|
// WithNewSnapshot wraps `containerd.WithNewSnapshot` so that if creating the
|
||||||
// snapshot fails we make sure the image is actually unpacked and and retry.
|
// snapshot fails we make sure the image is actually unpacked and and retry.
|
||||||
func WithNewSnapshot(id string, i containerd.Image) containerd.NewContainerOpts {
|
func WithNewSnapshot(id string, i containerd.Image, opts ...snapshots.Opt) containerd.NewContainerOpts {
|
||||||
f := containerd.WithNewSnapshot(id, i)
|
f := containerd.WithNewSnapshot(id, i, opts...)
|
||||||
return func(ctx context.Context, client *containerd.Client, c *containers.Container) error {
|
return func(ctx context.Context, client *containerd.Client, c *containers.Container) error {
|
||||||
if err := f(ctx, client, c); err != nil {
|
if err := f(ctx, client, c); err != nil {
|
||||||
if !errdefs.IsNotFound(err) {
|
if !errdefs.IsNotFound(err) {
|
||||||
|
@ -24,6 +24,7 @@ import (
|
|||||||
"github.com/containerd/containerd/containers"
|
"github.com/containerd/containerd/containers"
|
||||||
"github.com/containerd/containerd/log"
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/containerd/containerd/oci"
|
"github.com/containerd/containerd/oci"
|
||||||
|
"github.com/containerd/containerd/snapshots"
|
||||||
"github.com/containerd/typeurl"
|
"github.com/containerd/typeurl"
|
||||||
"github.com/davecgh/go-spew/spew"
|
"github.com/davecgh/go-spew/spew"
|
||||||
imagespec "github.com/opencontainers/image-spec/specs-go/v1"
|
imagespec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
@ -180,6 +181,7 @@ func (c *criService) CreateContainer(ctx context.Context, r *runtime.CreateConta
|
|||||||
|
|
||||||
log.G(ctx).Debugf("Container %q spec: %#+v", id, spew.NewFormatter(spec))
|
log.G(ctx).Debugf("Container %q spec: %#+v", id, spew.NewFormatter(spec))
|
||||||
|
|
||||||
|
snapshotterOpt := snapshots.WithLabels(config.Annotations)
|
||||||
// Set snapshotter before any other options.
|
// Set snapshotter before any other options.
|
||||||
opts := []containerd.NewContainerOpts{
|
opts := []containerd.NewContainerOpts{
|
||||||
containerd.WithSnapshotter(c.config.ContainerdConfig.Snapshotter),
|
containerd.WithSnapshotter(c.config.ContainerdConfig.Snapshotter),
|
||||||
@ -188,7 +190,7 @@ func (c *criService) CreateContainer(ctx context.Context, r *runtime.CreateConta
|
|||||||
// the runtime (runc) a chance to modify (e.g. to create mount
|
// the runtime (runc) a chance to modify (e.g. to create mount
|
||||||
// points corresponding to spec.Mounts) before making the
|
// points corresponding to spec.Mounts) before making the
|
||||||
// rootfs readonly (requested by spec.Root.Readonly).
|
// rootfs readonly (requested by spec.Root.Readonly).
|
||||||
customopts.WithNewSnapshot(id, containerdImage),
|
customopts.WithNewSnapshot(id, containerdImage, snapshotterOpt),
|
||||||
}
|
}
|
||||||
if len(volumeMounts) > 0 {
|
if len(volumeMounts) > 0 {
|
||||||
mountMap := make(map[string]string)
|
mountMap := make(map[string]string)
|
||||||
|
@ -44,6 +44,7 @@ import (
|
|||||||
"github.com/containerd/containerd/pkg/cri/util"
|
"github.com/containerd/containerd/pkg/cri/util"
|
||||||
ctrdutil "github.com/containerd/containerd/pkg/cri/util"
|
ctrdutil "github.com/containerd/containerd/pkg/cri/util"
|
||||||
"github.com/containerd/containerd/pkg/netns"
|
"github.com/containerd/containerd/pkg/netns"
|
||||||
|
"github.com/containerd/containerd/snapshots"
|
||||||
selinux "github.com/opencontainers/selinux/go-selinux"
|
selinux "github.com/opencontainers/selinux/go-selinux"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -190,9 +191,11 @@ func (c *criService) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandbox
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "failed to generate runtime options")
|
return nil, errors.Wrap(err, "failed to generate runtime options")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshotterOpt := snapshots.WithLabels(config.Annotations)
|
||||||
opts := []containerd.NewContainerOpts{
|
opts := []containerd.NewContainerOpts{
|
||||||
containerd.WithSnapshotter(c.config.ContainerdConfig.Snapshotter),
|
containerd.WithSnapshotter(c.config.ContainerdConfig.Snapshotter),
|
||||||
customopts.WithNewSnapshot(id, containerdImage),
|
customopts.WithNewSnapshot(id, containerdImage, snapshotterOpt),
|
||||||
containerd.WithSpec(spec, specOpts...),
|
containerd.WithSpec(spec, specOpts...),
|
||||||
containerd.WithContainerLabels(sandboxLabels),
|
containerd.WithContainerLabels(sandboxLabels),
|
||||||
containerd.WithContainerExtension(sandboxMetadataExtension, &sandbox.Metadata),
|
containerd.WithContainerExtension(sandboxMetadataExtension, &sandbox.Metadata),
|
||||||
|
@ -346,7 +346,7 @@ func (s *snapshotter) createSnapshot(ctx context.Context, kind snapshots.Kind, k
|
|||||||
defer scratchSource.Close()
|
defer scratchSource.Close()
|
||||||
|
|
||||||
// TODO: JTERRY75 - This has to be called sandbox.vhdx for the time
|
// TODO: JTERRY75 - This has to be called sandbox.vhdx for the time
|
||||||
// being but it really is the scratch.vhdx Using this naming convention
|
// being but it really is the scratch.vhdx. Using this naming convention
|
||||||
// for now but this is not the kubernetes sandbox.
|
// for now but this is not the kubernetes sandbox.
|
||||||
//
|
//
|
||||||
// Create the sandbox.vhdx for this snapshot from the cache.
|
// Create the sandbox.vhdx for this snapshot from the cache.
|
||||||
@ -371,7 +371,7 @@ func (s *snapshotter) createSnapshot(ctx context.Context, kind snapshots.Kind, k
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *snapshotter) openOrCreateScratch(ctx context.Context, sizeGB int) (_ *os.File, err error) {
|
func (s *snapshotter) openOrCreateScratch(ctx context.Context, sizeGB int) (_ *os.File, err error) {
|
||||||
// Create the scratch.vhdx cache file if it doesn't already exit.
|
// Create the scratch.vhdx cache file if it doesn't already exist.
|
||||||
s.scratchLock.Lock()
|
s.scratchLock.Lock()
|
||||||
defer s.scratchLock.Unlock()
|
defer s.scratchLock.Unlock()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user