From c68323010ab5cf80beb7c825d4a2da11bbc541e2 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 24 Aug 2022 15:34:27 +0200 Subject: [PATCH] daemon: remove SnapshotterFromGraphDriver mapping It was decided in upstream to not do mapping of graphdriver-names to snapshotters, and instead require the actual name of the snapshotter to be used when configuring the daemon's storage driver. This patch removes the code that was used for mapping to make it closer to upstream. Signed-off-by: Sebastiaan van Stijn --- daemon/containerd/snapshotters.go | 19 --------- daemon/containerd/snapshotters_test.go | 58 -------------------------- daemon/daemon.go | 17 ++++---- 3 files changed, 8 insertions(+), 86 deletions(-) delete mode 100644 daemon/containerd/snapshotters.go delete mode 100644 daemon/containerd/snapshotters_test.go 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,