From 54ce8ed5874ea7d0ad882470aa1f9b39a681cd2f Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 22 Aug 2022 18:36:03 +0200 Subject: [PATCH 1/2] info: add driver-type With this patch: mkdir -p /etc/docker/ echo '{"features":{"containerd-snapshotter":true}}' > /etc/docker/daemon.json dockerd docker info ... Storage Driver: overlayfs driver-type: io.containerd.snapshotter.v1 Logging Driver: json-file Signed-off-by: Sebastiaan van Stijn --- daemon/containerd/service.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/daemon/containerd/service.go b/daemon/containerd/service.go index 953ff1ee963b7..84bf86866d4f3 100644 --- a/daemon/containerd/service.go +++ b/daemon/containerd/service.go @@ -7,6 +7,7 @@ import ( "github.com/containerd/containerd" cerrdefs "github.com/containerd/containerd/errdefs" + "github.com/containerd/containerd/plugin" "github.com/containerd/containerd/snapshots" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" @@ -70,7 +71,10 @@ func (i *ImageService) CreateLayer(container *container.Container, initFunc laye // LayerStoreStatus returns the status for each layer store // called from info.go func (i *ImageService) LayerStoreStatus() [][2]string { - return [][2]string{} + // TODO(thaJeztah) do we want to add more details about the driver here? + return [][2]string{ + {"driver-type", string(plugin.SnapshotPlugin)}, + } } // GetLayerMountID returns the mount ID for a layer From 65789b75a2f4e6ee91630bb41c73529a37dff117 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 22 Aug 2022 19:53:07 +0200 Subject: [PATCH 2/2] integration-cli: add utility to check if snapshotters are enabled Signed-off-by: Sebastiaan van Stijn --- integration-cli/docker_cli_inspect_test.go | 3 +-- integration-cli/requirements_test.go | 12 ++++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/integration-cli/docker_cli_inspect_test.go b/integration-cli/docker_cli_inspect_test.go index 0fe9106585186..1daabeac5b683 100644 --- a/integration-cli/docker_cli_inspect_test.go +++ b/integration-cli/docker_cli_inspect_test.go @@ -42,8 +42,7 @@ func (s *DockerCLIInspectSuite) TestInspectImage(c *testing.T) { // fails, fix the difference in the image serialization instead of // updating this hash. imageTestID := "sha256:11f64303f0f7ffdc71f001788132bca5346831939a956e3e975c93267d89a16d" - usesContainerdSnapshotter := false // TODO(vvoland): Check for feature flag - if usesContainerdSnapshotter { + if containerdSnapshotterEnabled() { // Under containerd ID of the image is the digest of the manifest list. imageTestID = "sha256:e43ca824363c5c56016f6ede3a9035afe0e9bd43333215e0b0bde6193969725d" } diff --git a/integration-cli/requirements_test.go b/integration-cli/requirements_test.go index 3c4e19478152c..c2b16fc2f836d 100644 --- a/integration-cli/requirements_test.go +++ b/integration-cli/requirements_test.go @@ -10,6 +10,7 @@ import ( "testing" "time" + "github.com/containerd/containerd/plugin" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/versions" @@ -99,6 +100,17 @@ func Devicemapper() bool { return strings.HasPrefix(testEnv.DaemonInfo.Driver, "devicemapper") } +// containerdSnapshotterEnabled checks if the daemon in the test-environment is +// configured with containerd-snapshotters enabled. +func containerdSnapshotterEnabled() bool { + for _, v := range testEnv.DaemonInfo.DriverStatus { + if v[0] == "driver-type" { + return v[1] == string(plugin.SnapshotPlugin) + } + } + return false +} + func IPv6() bool { cmd := exec.Command("test", "-f", "/proc/net/if_inet6") return cmd.Run() != nil