Kaynağa Gözat

Merge pull request #43735 from ndeloof/containerd-snapshotter-ff

introduce Containerd-snapshotter feature flag
Sebastiaan van Stijn 3 yıl önce
ebeveyn
işleme
094069adc7
2 değiştirilmiş dosya ile 16 ekleme ve 4 silme
  1. 10 0
      daemon/daemon.go
  2. 6 4
      daemon/oci_linux.go

+ 10 - 0
daemon/daemon.go

@@ -147,6 +147,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 (

+ 6 - 4
daemon/oci_linux.go

@@ -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