Browse Source

Merge pull request #46008 from thaJeztah/c8d_nits

c8d: some minor cleanups
Sebastiaan van Stijn 2 years ago
parent
commit
8e51b8b59c
8 changed files with 70 additions and 80 deletions
  1. 10 18
      daemon/content.go
  2. 53 55
      daemon/daemon.go
  3. 1 1
      daemon/daemon_unix.go
  4. 2 2
      daemon/daemon_windows.go
  5. 1 1
      daemon/delete.go
  6. 1 1
      daemon/exec.go
  7. 1 1
      daemon/exec_linux.go
  8. 1 1
      daemon/oci_linux.go

+ 10 - 18
daemon/content.go

@@ -16,7 +16,7 @@ import (
 	"go.etcd.io/bbolt"
 	"go.etcd.io/bbolt"
 )
 )
 
 
-func (daemon *Daemon) configureLocalContentStore(ns string) (content.Store, leases.Manager, error) {
+func (daemon *Daemon) configureLocalContentStore(ns string) (*namespacedContent, *namespacedLeases, error) {
 	if err := os.MkdirAll(filepath.Join(daemon.root, "content"), 0o700); err != nil {
 	if err := os.MkdirAll(filepath.Join(daemon.root, "content"), 0o700); err != nil {
 		return nil, nil, errors.Wrap(err, "error creating dir for content store")
 		return nil, nil, errors.Wrap(err, "error creating dir for content store")
 	}
 	}
@@ -30,7 +30,15 @@ func (daemon *Daemon) configureLocalContentStore(ns string) (content.Store, leas
 	}
 	}
 	md := metadata.NewDB(db, cs, nil)
 	md := metadata.NewDB(db, cs, nil)
 	daemon.mdDB = db
 	daemon.mdDB = db
-	return namespacedContentProvider(md.ContentStore(), ns), namespacedLeaseManager(metadata.NewLeaseManager(md), ns), nil
+	cp := &namespacedContent{
+		ns:       ns,
+		provider: md.ContentStore(),
+	}
+	lm := &namespacedLeases{
+		ns:      ns,
+		manager: metadata.NewLeaseManager(md),
+	}
+	return cp, lm, nil
 }
 }
 
 
 // withDefaultNamespace sets the given namespace on the context if the current
 // withDefaultNamespace sets the given namespace on the context if the current
@@ -105,14 +113,6 @@ func (cp namespacedContent) ReaderAt(ctx context.Context, desc ocispec.Descripto
 	return cp.provider.ReaderAt(withDefaultNamespace(ctx, cp.ns), desc)
 	return cp.provider.ReaderAt(withDefaultNamespace(ctx, cp.ns), desc)
 }
 }
 
 
-// namespacedContentProvider sets the namespace if missing before calling the inner provider
-func namespacedContentProvider(provider content.Store, ns string) content.Store {
-	return namespacedContent{
-		ns,
-		provider,
-	}
-}
-
 type namespacedLeases struct {
 type namespacedLeases struct {
 	ns      string
 	ns      string
 	manager leases.Manager
 	manager leases.Manager
@@ -147,11 +147,3 @@ func (nl namespacedLeases) List(ctx context.Context, filter ...string) ([]leases
 func (nl namespacedLeases) ListResources(ctx context.Context, lease leases.Lease) ([]leases.Resource, error) {
 func (nl namespacedLeases) ListResources(ctx context.Context, lease leases.Lease) ([]leases.Resource, error) {
 	return nl.manager.ListResources(withDefaultNamespace(ctx, nl.ns), lease)
 	return nl.manager.ListResources(withDefaultNamespace(ctx, nl.ns), lease)
 }
 }
-
-// namespacedLeaseManager sets the namespace if missing before calling the inner manager
-func namespacedLeaseManager(manager leases.Manager, ns string) leases.Manager {
-	return namespacedLeases{
-		ns,
-		manager,
-	}
-}

+ 53 - 55
daemon/daemon.go

@@ -110,7 +110,7 @@ type Daemon struct {
 	PluginStore           *plugin.Store // TODO: remove
 	PluginStore           *plugin.Store // TODO: remove
 	pluginManager         *plugin.Manager
 	pluginManager         *plugin.Manager
 	linkIndex             *linkIndex
 	linkIndex             *linkIndex
-	containerdCli         *containerd.Client
+	containerdClient      *containerd.Client
 	containerd            libcontainerdtypes.Client
 	containerd            libcontainerdtypes.Client
 	defaultIsolation      containertypes.Isolation // Default isolation mode on Windows
 	defaultIsolation      containertypes.Isolation // Default isolation mode on Windows
 	clusterProvider       cluster.Provider
 	clusterProvider       cluster.Provider
@@ -554,14 +554,14 @@ func (daemon *Daemon) restore(cfg *configStore) error {
 	}
 	}
 	group.Wait()
 	group.Wait()
 
 
-	for c, notifier := range restartContainers {
+	for c, notifyChan := range restartContainers {
 		group.Add(1)
 		group.Add(1)
 		go func(c *container.Container, chNotify chan struct{}) {
 		go func(c *container.Container, chNotify chan struct{}) {
 			_ = sem.Acquire(context.Background(), 1)
 			_ = sem.Acquire(context.Background(), 1)
 
 
-			log := log.G(context.TODO()).WithField("container", c.ID)
+			logger := log.G(context.TODO()).WithField("container", c.ID)
 
 
-			log.Debug("starting container")
+			logger.Debug("starting container")
 
 
 			// ignore errors here as this is a best effort to wait for children to be
 			// ignore errors here as this is a best effort to wait for children to be
 			//   running before we try to start the container
 			//   running before we try to start the container
@@ -579,16 +579,16 @@ func (daemon *Daemon) restore(cfg *configStore) error {
 			}
 			}
 
 
 			if err := daemon.prepareMountPoints(c); err != nil {
 			if err := daemon.prepareMountPoints(c); err != nil {
-				log.WithError(err).Error("failed to prepare mount points for container")
+				logger.WithError(err).Error("failed to prepare mount points for container")
 			}
 			}
 			if err := daemon.containerStart(context.Background(), cfg, c, "", "", true); err != nil {
 			if err := daemon.containerStart(context.Background(), cfg, c, "", "", true); err != nil {
-				log.WithError(err).Error("failed to start container")
+				logger.WithError(err).Error("failed to start container")
 			}
 			}
 			close(chNotify)
 			close(chNotify)
 
 
 			sem.Release(1)
 			sem.Release(1)
 			group.Done()
 			group.Done()
-		}(c, notifier)
+		}(c, notifyChan)
 	}
 	}
 	group.Wait()
 	group.Wait()
 
 
@@ -822,7 +822,7 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S
 	if err := initRuntimesDir(config); err != nil {
 	if err := initRuntimesDir(config); err != nil {
 		return nil, err
 		return nil, err
 	}
 	}
-	runtimes, err := setupRuntimes(config)
+	rts, err := setupRuntimes(config)
 	if err != nil {
 	if err != nil {
 		return nil, err
 		return nil, err
 	}
 	}
@@ -831,11 +831,11 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S
 		PluginStore: pluginStore,
 		PluginStore: pluginStore,
 		startupDone: make(chan struct{}),
 		startupDone: make(chan struct{}),
 	}
 	}
-	configStore := &configStore{
+	cfgStore := &configStore{
 		Config:   *config,
 		Config:   *config,
-		Runtimes: runtimes,
+		Runtimes: rts,
 	}
 	}
-	d.configStore.Store(configStore)
+	d.configStore.Store(cfgStore)
 
 
 	// TEST_INTEGRATION_USE_SNAPSHOTTER is used for integration tests only.
 	// TEST_INTEGRATION_USE_SNAPSHOTTER is used for integration tests only.
 	if os.Getenv("TEST_INTEGRATION_USE_SNAPSHOTTER") != "" {
 	if os.Getenv("TEST_INTEGRATION_USE_SNAPSHOTTER") != "" {
@@ -855,27 +855,27 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S
 		}
 		}
 	}()
 	}()
 
 
-	if err := d.setGenericResources(&configStore.Config); err != nil {
+	if err := d.setGenericResources(&cfgStore.Config); err != nil {
 		return nil, err
 		return nil, err
 	}
 	}
 	// set up SIGUSR1 handler on Unix-like systems, or a Win32 global event
 	// set up SIGUSR1 handler on Unix-like systems, or a Win32 global event
 	// on Windows to dump Go routine stacks
 	// on Windows to dump Go routine stacks
-	stackDumpDir := configStore.Root
-	if execRoot := configStore.GetExecRoot(); execRoot != "" {
+	stackDumpDir := cfgStore.Root
+	if execRoot := cfgStore.GetExecRoot(); execRoot != "" {
 		stackDumpDir = execRoot
 		stackDumpDir = execRoot
 	}
 	}
 	d.setupDumpStackTrap(stackDumpDir)
 	d.setupDumpStackTrap(stackDumpDir)
 
 
-	if err := d.setupSeccompProfile(&configStore.Config); err != nil {
+	if err := d.setupSeccompProfile(&cfgStore.Config); err != nil {
 		return nil, err
 		return nil, err
 	}
 	}
 
 
 	// Set the default isolation mode (only applicable on Windows)
 	// Set the default isolation mode (only applicable on Windows)
-	if err := d.setDefaultIsolation(&configStore.Config); err != nil {
+	if err := d.setDefaultIsolation(&cfgStore.Config); err != nil {
 		return nil, fmt.Errorf("error setting default isolation mode: %v", err)
 		return nil, fmt.Errorf("error setting default isolation mode: %v", err)
 	}
 	}
 
 
-	if err := configureMaxThreads(&configStore.Config); err != nil {
+	if err := configureMaxThreads(&cfgStore.Config); err != nil {
 		log.G(ctx).Warnf("Failed to configure golang's threads limit: %v", err)
 		log.G(ctx).Warnf("Failed to configure golang's threads limit: %v", err)
 	}
 	}
 
 
@@ -884,7 +884,7 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S
 		log.G(ctx).Errorf(err.Error())
 		log.G(ctx).Errorf(err.Error())
 	}
 	}
 
 
-	daemonRepo := filepath.Join(configStore.Root, "containers")
+	daemonRepo := filepath.Join(cfgStore.Root, "containers")
 	if err := idtools.MkdirAllAndChown(daemonRepo, 0o710, idtools.Identity{
 	if err := idtools.MkdirAllAndChown(daemonRepo, 0o710, idtools.Identity{
 		UID: idtools.CurrentIdentity().UID,
 		UID: idtools.CurrentIdentity().UID,
 		GID: rootIDs.GID,
 		GID: rootIDs.GID,
@@ -896,7 +896,7 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S
 		// Note that permissions (0o700) are ignored on Windows; passing them to
 		// Note that permissions (0o700) are ignored on Windows; passing them to
 		// show intent only. We could consider using idtools.MkdirAndChown here
 		// show intent only. We could consider using idtools.MkdirAndChown here
 		// to apply an ACL.
 		// to apply an ACL.
-		if err = os.Mkdir(filepath.Join(configStore.Root, "credentialspecs"), 0o700); err != nil && !errors.Is(err, os.ErrExist) {
+		if err = os.Mkdir(filepath.Join(cfgStore.Root, "credentialspecs"), 0o700); err != nil && !errors.Is(err, os.ErrExist) {
 			return nil, err
 			return nil, err
 		}
 		}
 	}
 	}
@@ -904,7 +904,7 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S
 	d.registryService = registryService
 	d.registryService = registryService
 	dlogger.RegisterPluginGetter(d.PluginStore)
 	dlogger.RegisterPluginGetter(d.PluginStore)
 
 
-	metricsSockPath, err := d.listenMetricsSock(&configStore.Config)
+	metricsSockPath, err := d.listenMetricsSock(&cfgStore.Config)
 	if err != nil {
 	if err != nil {
 		return nil, err
 		return nil, err
 	}
 	}
@@ -943,20 +943,20 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S
 		grpc.WithDefaultCallOptions(grpc.MaxCallSendMsgSize(defaults.DefaultMaxSendMsgSize)),
 		grpc.WithDefaultCallOptions(grpc.MaxCallSendMsgSize(defaults.DefaultMaxSendMsgSize)),
 	}
 	}
 
 
-	if configStore.ContainerdAddr != "" {
-		d.containerdCli, err = containerd.New(configStore.ContainerdAddr, containerd.WithDefaultNamespace(configStore.ContainerdNamespace), containerd.WithDialOpts(gopts), containerd.WithTimeout(60*time.Second))
+	if cfgStore.ContainerdAddr != "" {
+		d.containerdClient, err = containerd.New(cfgStore.ContainerdAddr, containerd.WithDefaultNamespace(cfgStore.ContainerdNamespace), containerd.WithDialOpts(gopts), containerd.WithTimeout(60*time.Second))
 		if err != nil {
 		if err != nil {
-			return nil, errors.Wrapf(err, "failed to dial %q", configStore.ContainerdAddr)
+			return nil, errors.Wrapf(err, "failed to dial %q", cfgStore.ContainerdAddr)
 		}
 		}
 	}
 	}
 
 
 	createPluginExec := func(m *plugin.Manager) (plugin.Executor, error) {
 	createPluginExec := func(m *plugin.Manager) (plugin.Executor, error) {
 		var pluginCli *containerd.Client
 		var pluginCli *containerd.Client
 
 
-		if configStore.ContainerdAddr != "" {
-			pluginCli, err = containerd.New(configStore.ContainerdAddr, containerd.WithDefaultNamespace(configStore.ContainerdPluginNamespace), containerd.WithDialOpts(gopts), containerd.WithTimeout(60*time.Second))
+		if cfgStore.ContainerdAddr != "" {
+			pluginCli, err = containerd.New(cfgStore.ContainerdAddr, containerd.WithDefaultNamespace(cfgStore.ContainerdPluginNamespace), containerd.WithDialOpts(gopts), containerd.WithTimeout(60*time.Second))
 			if err != nil {
 			if err != nil {
-				return nil, errors.Wrapf(err, "failed to dial %q", configStore.ContainerdAddr)
+				return nil, errors.Wrapf(err, "failed to dial %q", cfgStore.ContainerdAddr)
 			}
 			}
 		}
 		}
 
 
@@ -965,22 +965,22 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S
 			shimOpts interface{}
 			shimOpts interface{}
 		)
 		)
 		if runtime.GOOS != "windows" {
 		if runtime.GOOS != "windows" {
-			shim, shimOpts, err = runtimes.Get("")
+			shim, shimOpts, err = rts.Get("")
 			if err != nil {
 			if err != nil {
 				return nil, err
 				return nil, err
 			}
 			}
 		}
 		}
-		return pluginexec.New(ctx, getPluginExecRoot(&configStore.Config), pluginCli, configStore.ContainerdPluginNamespace, m, shim, shimOpts)
+		return pluginexec.New(ctx, getPluginExecRoot(&cfgStore.Config), pluginCli, cfgStore.ContainerdPluginNamespace, m, shim, shimOpts)
 	}
 	}
 
 
 	// Plugin system initialization should happen before restore. Do not change order.
 	// Plugin system initialization should happen before restore. Do not change order.
 	d.pluginManager, err = plugin.NewManager(plugin.ManagerConfig{
 	d.pluginManager, err = plugin.NewManager(plugin.ManagerConfig{
-		Root:               filepath.Join(configStore.Root, "plugins"),
-		ExecRoot:           getPluginExecRoot(&configStore.Config),
+		Root:               filepath.Join(cfgStore.Root, "plugins"),
+		ExecRoot:           getPluginExecRoot(&cfgStore.Config),
 		Store:              d.PluginStore,
 		Store:              d.PluginStore,
 		CreateExecutor:     createPluginExec,
 		CreateExecutor:     createPluginExec,
 		RegistryService:    registryService,
 		RegistryService:    registryService,
-		LiveRestoreEnabled: configStore.LiveRestoreEnabled,
+		LiveRestoreEnabled: cfgStore.LiveRestoreEnabled,
 		LogPluginEvent:     d.LogPluginEvent, // todo: make private
 		LogPluginEvent:     d.LogPluginEvent, // todo: make private
 		AuthzMiddleware:    authzMiddleware,
 		AuthzMiddleware:    authzMiddleware,
 	})
 	})
@@ -988,13 +988,13 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S
 		return nil, errors.Wrap(err, "couldn't create plugin manager")
 		return nil, errors.Wrap(err, "couldn't create plugin manager")
 	}
 	}
 
 
-	d.defaultLogConfig, err = defaultLogConfig(&configStore.Config)
+	d.defaultLogConfig, err = defaultLogConfig(&cfgStore.Config)
 	if err != nil {
 	if err != nil {
 		return nil, errors.Wrap(err, "failed to set log opts")
 		return nil, errors.Wrap(err, "failed to set log opts")
 	}
 	}
 	log.G(ctx).Debugf("Using default logging driver %s", d.defaultLogConfig.Type)
 	log.G(ctx).Debugf("Using default logging driver %s", d.defaultLogConfig.Type)
 
 
-	d.volumes, err = volumesservice.NewVolumeService(configStore.Root, d.PluginStore, rootIDs, d)
+	d.volumes, err = volumesservice.NewVolumeService(cfgStore.Root, d.PluginStore, rootIDs, d)
 	if err != nil {
 	if err != nil {
 		return nil, err
 		return nil, err
 	}
 	}
@@ -1007,11 +1007,11 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S
 	// at this point.
 	// at this point.
 	//
 	//
 	// TODO(thaJeztah) add a utility to only collect the CgroupDevicesEnabled information
 	// TODO(thaJeztah) add a utility to only collect the CgroupDevicesEnabled information
-	if runtime.GOOS == "linux" && !userns.RunningInUserNS() && !getSysInfo(&configStore.Config).CgroupDevicesEnabled {
+	if runtime.GOOS == "linux" && !userns.RunningInUserNS() && !getSysInfo(&cfgStore.Config).CgroupDevicesEnabled {
 		return nil, errors.New("Devices cgroup isn't mounted")
 		return nil, errors.New("Devices cgroup isn't mounted")
 	}
 	}
 
 
-	d.id, err = loadOrCreateID(filepath.Join(configStore.Root, "engine-id"))
+	d.id, err = loadOrCreateID(filepath.Join(cfgStore.Root, "engine-id"))
 	if err != nil {
 	if err != nil {
 		return nil, err
 		return nil, err
 	}
 	}
@@ -1024,7 +1024,7 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S
 	d.statsCollector = d.newStatsCollector(1 * time.Second)
 	d.statsCollector = d.newStatsCollector(1 * time.Second)
 
 
 	d.EventsService = events.New()
 	d.EventsService = events.New()
-	d.root = configStore.Root
+	d.root = cfgStore.Root
 	d.idMapping = idMapping
 	d.idMapping = idMapping
 
 
 	d.linkIndex = newLinkIndex()
 	d.linkIndex = newLinkIndex()
@@ -1039,7 +1039,7 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S
 	} else if driverName != "" {
 	} else if driverName != "" {
 		log.G(ctx).Infof("Setting the storage driver from the $DOCKER_DRIVER environment variable (%s)", driverName)
 		log.G(ctx).Infof("Setting the storage driver from the $DOCKER_DRIVER environment variable (%s)", driverName)
 	} else {
 	} else {
-		driverName = configStore.GraphDriver
+		driverName = cfgStore.GraphDriver
 	}
 	}
 
 
 	if d.UsesSnapshotter() {
 	if d.UsesSnapshotter() {
@@ -1055,11 +1055,11 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S
 
 
 		// Configure and validate the kernels security support. Note this is a Linux/FreeBSD
 		// Configure and validate the kernels security support. Note this is a Linux/FreeBSD
 		// operation only, so it is safe to pass *just* the runtime OS graphdriver.
 		// operation only, so it is safe to pass *just* the runtime OS graphdriver.
-		if err := configureKernelSecuritySupport(&configStore.Config, driverName); err != nil {
+		if err := configureKernelSecuritySupport(&cfgStore.Config, driverName); err != nil {
 			return nil, err
 			return nil, err
 		}
 		}
 		d.imageService = ctrd.NewService(ctrd.ImageServiceConfig{
 		d.imageService = ctrd.NewService(ctrd.ImageServiceConfig{
-			Client:          d.containerdCli,
+			Client:          d.containerdClient,
 			Containers:      d.containers,
 			Containers:      d.containers,
 			Snapshotter:     driverName,
 			Snapshotter:     driverName,
 			RegistryHosts:   d.RegistryHosts,
 			RegistryHosts:   d.RegistryHosts,
@@ -1069,13 +1069,13 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S
 		})
 		})
 	} else {
 	} else {
 		layerStore, err := layer.NewStoreFromOptions(layer.StoreOptions{
 		layerStore, err := layer.NewStoreFromOptions(layer.StoreOptions{
-			Root:                      configStore.Root,
-			MetadataStorePathTemplate: filepath.Join(configStore.Root, "image", "%s", "layerdb"),
+			Root:                      cfgStore.Root,
+			MetadataStorePathTemplate: filepath.Join(cfgStore.Root, "image", "%s", "layerdb"),
 			GraphDriver:               driverName,
 			GraphDriver:               driverName,
-			GraphDriverOptions:        configStore.GraphOptions,
+			GraphDriverOptions:        cfgStore.GraphOptions,
 			IDMapping:                 idMapping,
 			IDMapping:                 idMapping,
 			PluginGetter:              d.PluginStore,
 			PluginGetter:              d.PluginStore,
-			ExperimentalEnabled:       configStore.Experimental,
+			ExperimentalEnabled:       cfgStore.Experimental,
 		})
 		})
 		if err != nil {
 		if err != nil {
 			return nil, err
 			return nil, err
@@ -1083,11 +1083,11 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S
 
 
 		// Configure and validate the kernels security support. Note this is a Linux/FreeBSD
 		// Configure and validate the kernels security support. Note this is a Linux/FreeBSD
 		// operation only, so it is safe to pass *just* the runtime OS graphdriver.
 		// operation only, so it is safe to pass *just* the runtime OS graphdriver.
-		if err := configureKernelSecuritySupport(&configStore.Config, layerStore.DriverName()); err != nil {
+		if err := configureKernelSecuritySupport(&cfgStore.Config, layerStore.DriverName()); err != nil {
 			return nil, err
 			return nil, err
 		}
 		}
 
 
-		imageRoot := filepath.Join(configStore.Root, "image", layerStore.DriverName())
+		imageRoot := filepath.Join(cfgStore.Root, "image", layerStore.DriverName())
 		ifs, err := image.NewFSStoreBackend(filepath.Join(imageRoot, "imagedb"))
 		ifs, err := image.NewFSStoreBackend(filepath.Join(imageRoot, "imagedb"))
 		if err != nil {
 		if err != nil {
 			return nil, err
 			return nil, err
@@ -1137,16 +1137,14 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S
 		// containerd is not currently supported with Windows.
 		// containerd is not currently supported with Windows.
 		// So sometimes d.containerdCli will be nil
 		// So sometimes d.containerdCli will be nil
 		// In that case we'll create a local content store... but otherwise we'll use containerd
 		// In that case we'll create a local content store... but otherwise we'll use containerd
-		if d.containerdCli != nil {
-			imgSvcConfig.Leases = d.containerdCli.LeasesService()
-			imgSvcConfig.ContentStore = d.containerdCli.ContentStore()
+		if d.containerdClient != nil {
+			imgSvcConfig.Leases = d.containerdClient.LeasesService()
+			imgSvcConfig.ContentStore = d.containerdClient.ContentStore()
 		} else {
 		} else {
-			cs, lm, err := d.configureLocalContentStore(config.ContainerdNamespace)
+			imgSvcConfig.ContentStore, imgSvcConfig.Leases, err = d.configureLocalContentStore(config.ContainerdNamespace)
 			if err != nil {
 			if err != nil {
 				return nil, err
 				return nil, err
 			}
 			}
-			imgSvcConfig.ContentStore = cs
-			imgSvcConfig.Leases = lm
 		}
 		}
 
 
 		// TODO: imageStore, distributionMetadataStore, and ReferenceStore are only
 		// TODO: imageStore, distributionMetadataStore, and ReferenceStore are only
@@ -1161,11 +1159,11 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S
 
 
 	go d.execCommandGC()
 	go d.execCommandGC()
 
 
-	if err := d.initLibcontainerd(ctx, &configStore.Config); err != nil {
+	if err := d.initLibcontainerd(ctx, &cfgStore.Config); err != nil {
 		return nil, err
 		return nil, err
 	}
 	}
 
 
-	if err := d.restore(configStore); err != nil {
+	if err := d.restore(cfgStore); err != nil {
 		return nil, err
 		return nil, err
 	}
 	}
 	close(d.startupDone)
 	close(d.startupDone)
@@ -1316,8 +1314,8 @@ func (daemon *Daemon) Shutdown(ctx context.Context) error {
 		daemon.netController.Stop()
 		daemon.netController.Stop()
 	}
 	}
 
 
-	if daemon.containerdCli != nil {
-		daemon.containerdCli.Close()
+	if daemon.containerdClient != nil {
+		daemon.containerdClient.Close()
 	}
 	}
 
 
 	if daemon.mdDB != nil {
 	if daemon.mdDB != nil {

+ 1 - 1
daemon/daemon_unix.go

@@ -1493,7 +1493,7 @@ func (daemon *Daemon) initLibcontainerd(ctx context.Context, cfg *config.Config)
 	var err error
 	var err error
 	daemon.containerd, err = remote.NewClient(
 	daemon.containerd, err = remote.NewClient(
 		ctx,
 		ctx,
-		daemon.containerdCli,
+		daemon.containerdClient,
 		filepath.Join(cfg.ExecRoot, "containerd"),
 		filepath.Join(cfg.ExecRoot, "containerd"),
 		cfg.ContainerdNamespace,
 		cfg.ContainerdNamespace,
 		daemon,
 		daemon,

+ 2 - 2
daemon/daemon_windows.go

@@ -576,7 +576,7 @@ func (daemon *Daemon) initLibcontainerd(ctx context.Context, cfg *config.Config)
 	case windowsV1RuntimeName:
 	case windowsV1RuntimeName:
 		daemon.containerd, err = local.NewClient(
 		daemon.containerd, err = local.NewClient(
 			ctx,
 			ctx,
-			daemon.containerdCli,
+			daemon.containerdClient,
 			filepath.Join(cfg.ExecRoot, "containerd"),
 			filepath.Join(cfg.ExecRoot, "containerd"),
 			cfg.ContainerdNamespace,
 			cfg.ContainerdNamespace,
 			daemon,
 			daemon,
@@ -587,7 +587,7 @@ func (daemon *Daemon) initLibcontainerd(ctx context.Context, cfg *config.Config)
 		}
 		}
 		daemon.containerd, err = remote.NewClient(
 		daemon.containerd, err = remote.NewClient(
 			ctx,
 			ctx,
-			daemon.containerdCli,
+			daemon.containerdClient,
 			filepath.Join(cfg.ExecRoot, "containerd"),
 			filepath.Join(cfg.ExecRoot, "containerd"),
 			cfg.ContainerdNamespace,
 			cfg.ContainerdNamespace,
 			daemon,
 			daemon,

+ 1 - 1
daemon/delete.go

@@ -144,7 +144,7 @@ func (daemon *Daemon) cleanupContainer(container *container.Container, config ty
 		container.RWLayer = nil
 		container.RWLayer = nil
 	} else {
 	} else {
 		if daemon.UsesSnapshotter() {
 		if daemon.UsesSnapshotter() {
-			ls := daemon.containerdCli.LeasesService()
+			ls := daemon.containerdClient.LeasesService()
 			lease := leases.Lease{
 			lease := leases.Lease{
 				ID: container.ID,
 				ID: container.ID,
 			}
 			}

+ 1 - 1
daemon/exec.go

@@ -218,7 +218,7 @@ func (daemon *Daemon) ContainerExecStart(ctx context.Context, name string, optio
 
 
 	p := &specs.Process{}
 	p := &specs.Process{}
 	if runtime.GOOS != "windows" {
 	if runtime.GOOS != "windows" {
-		ctr, err := daemon.containerdCli.LoadContainer(ctx, ec.Container.ID)
+		ctr, err := daemon.containerdClient.LoadContainer(ctx, ec.Container.ID)
 		if err != nil {
 		if err != nil {
 			return err
 			return err
 		}
 		}

+ 1 - 1
daemon/exec_linux.go

@@ -55,7 +55,7 @@ func (daemon *Daemon) execSetPlatformOpt(ctx context.Context, daemonCfg *config.
 	if len(ec.User) > 0 {
 	if len(ec.User) > 0 {
 		var err error
 		var err error
 		if daemon.UsesSnapshotter() {
 		if daemon.UsesSnapshotter() {
-			p.User, err = getUserFromContainerd(ctx, daemon.containerdCli, ec)
+			p.User, err = getUserFromContainerd(ctx, daemon.containerdClient, ec)
 			if err != nil {
 			if err != nil {
 				return err
 				return err
 			}
 			}

+ 1 - 1
daemon/oci_linux.go

@@ -1116,7 +1116,7 @@ func (daemon *Daemon) createSpec(ctx context.Context, daemonCfg *configStore, c
 		snapshotKey = c.ID
 		snapshotKey = c.ID
 	}
 	}
 
 
-	return &s, coci.ApplyOpts(ctx, daemon.containerdCli, &containers.Container{
+	return &s, coci.ApplyOpts(ctx, daemon.containerdClient, &containers.Container{
 		ID:          c.ID,
 		ID:          c.ID,
 		Snapshotter: snapshotter,
 		Snapshotter: snapshotter,
 		SnapshotKey: snapshotKey,
 		SnapshotKey: snapshotKey,