diff --git a/daemon/containerd/snapshotters.go b/daemon/containerd/snapshotters.go deleted file mode 100644 index bd9e4766827a7..0000000000000 --- a/daemon/containerd/snapshotters.go +++ /dev/null @@ -1,19 +0,0 @@ -package containerd - -import "github.com/containerd/containerd" - -// SnapshotterFromGraphDriver returns the containerd snapshotter name based on -// the supplied graphdriver name. It handles both legacy names and translates -// them into corresponding containerd snapshotter names. -func SnapshotterFromGraphDriver(graphDriver string) string { - switch graphDriver { - case "overlay", "overlay2": - return "overlayfs" - case "windowsfilter": - return "windows" - case "": - return containerd.DefaultSnapshotter - default: - return graphDriver - } -} diff --git a/daemon/containerd/snapshotters_test.go b/daemon/containerd/snapshotters_test.go deleted file mode 100644 index 9d05794bb5cfa..0000000000000 --- a/daemon/containerd/snapshotters_test.go +++ /dev/null @@ -1,58 +0,0 @@ -package containerd - -import ( - "testing" - - "github.com/containerd/containerd" - "gotest.tools/v3/assert" -) - -func TestSnapshotterFromGraphDriver(t *testing.T) { - testCases := []struct { - desc string - input string - expected string - }{ - { - desc: "empty defaults to containerd default", - input: "", - expected: containerd.DefaultSnapshotter, - }, - { - desc: "overlay -> overlayfs", - input: "overlay", - expected: "overlayfs", - }, - { - desc: "overlay2 -> overlayfs", - input: "overlay2", - expected: "overlayfs", - }, - { - desc: "windowsfilter -> windows", - input: "windowsfilter", - expected: "windows", - }, - { - desc: "containerd overlayfs", - input: "overlayfs", - expected: "overlayfs", - }, - { - desc: "containerd zfs", - input: "zfs", - expected: "zfs", - }, - { - desc: "unknown is unchanged", - input: "somefuturesnapshotter", - expected: "somefuturesnapshotter", - }, - } - for _, tc := range testCases { - tc := tc - t.Run(tc.desc, func(t *testing.T) { - assert.Equal(t, SnapshotterFromGraphDriver(tc.input), tc.expected) - }) - } -} diff --git a/daemon/daemon.go b/daemon/daemon.go index d6ac4cc713105..27169499ee716 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -987,28 +987,27 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S // Unix platforms however run a single graphdriver for all containers, and it can // be set through an environment variable, a daemon start parameter, or chosen through // initialization of the layerstore through driver priority order for example. - graphDriver := os.Getenv("DOCKER_DRIVER") + driverName := os.Getenv("DOCKER_DRIVER") if isWindows { - graphDriver = "windowsfilter" - } else if graphDriver != "" { - logrus.Infof("Setting the storage driver from the $DOCKER_DRIVER environment variable (%s)", graphDriver) + driverName = "windowsfilter" + } else if driverName != "" { + logrus.Infof("Setting the storage driver from the $DOCKER_DRIVER environment variable (%s)", driverName) } else { - graphDriver = config.GraphDriver + driverName = config.GraphDriver } if d.UsesSnapshotter() { - snapshotter := ctrd.SnapshotterFromGraphDriver(graphDriver) // 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. - if err := configureKernelSecuritySupport(config, snapshotter); err != nil { + if err := configureKernelSecuritySupport(config, driverName); err != nil { return nil, err } - d.imageService = ctrd.NewService(d.containerdCli, d.containers, snapshotter) + d.imageService = ctrd.NewService(d.containerdCli, d.containers, driverName) } else { layerStore, err := layer.NewStoreFromOptions(layer.StoreOptions{ Root: config.Root, MetadataStorePathTemplate: filepath.Join(config.Root, "image", "%s", "layerdb"), - GraphDriver: graphDriver, + GraphDriver: driverName, GraphDriverOptions: config.GraphOptions, IDMapping: idMapping, PluginGetter: d.PluginStore,