Skip to content

Commit

Permalink
introduce Containerd-snapshotter feature flag
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
  • Loading branch information
ndeloof committed Jun 22, 2022
1 parent 74286cb commit 1579c9c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 10 additions & 0 deletions daemon/daemon.go
Expand Up @@ -146,6 +146,16 @@ func (daemon *Daemon) Features() *map[string]bool {
return &daemon.configStore.Features
}

// usesSnapshotter returns true if feature flag to use containerd snapshotter is enabled
func (daemon *Daemon) usesSnapshotter() bool {
if daemon.configStore.Features != nil {
if b, ok := daemon.configStore.Features["Containerd-snapshotter"]; ok {
return b
}
}
return false
}

// RegistryHosts returns registry configuration in containerd resolvers format
func (daemon *Daemon) RegistryHosts() docker.RegistryHosts {
var (
Expand Down
10 changes: 6 additions & 4 deletions daemon/oci_linux.go
Expand Up @@ -720,16 +720,18 @@ func sysctlExists(s string) bool {
// WithCommonOptions sets common docker options
func WithCommonOptions(daemon *Daemon, c *container.Container) coci.SpecOpts {
return func(ctx context.Context, _ coci.Client, _ *containers.Container, s *coci.Spec) error {
if c.BaseFS == nil {
if c.BaseFS == nil && !daemon.usesSnapshotter() {
return errors.New("populateCommonSpec: BaseFS of container " + c.ID + " is unexpectedly nil")
}
linkedEnv, err := daemon.setupLinkedContainers(c)
if err != nil {
return err
}
s.Root = &specs.Root{
Path: c.BaseFS.Path(),
Readonly: c.HostConfig.ReadonlyRootfs,
if !daemon.usesSnapshotter() {
s.Root = &specs.Root{
Path: c.BaseFS.Path(),
Readonly: c.HostConfig.ReadonlyRootfs,
}
}
if err := c.SetupWorkingDirectory(daemon.idMapping.RootPair()); err != nil {
return err
Expand Down

0 comments on commit 1579c9c

Please sign in to comment.