From 0a004fd3619a0938c836648a6acbbdf6a1d4fcb5 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 17 Oct 2022 14:34:49 +0200 Subject: [PATCH 1/2] daemon: NewDaemon(): log message if containerd snapshotter is enabled Signed-off-by: Sebastiaan van Stijn --- daemon/daemon.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/daemon/daemon.go b/daemon/daemon.go index 272ab6bc5c..1b4d86f840 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -982,6 +982,8 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S } if d.UsesSnapshotter() { + logrus.Info("Starting daemon with containerd snapshotter integration enabled") + // FIXME(thaJeztah): implement automatic snapshotter-selection similar to graph-driver selection; see https://github.com/moby/moby/issues/44076 if driverName == "" { driverName = containerd.DefaultSnapshotter From 7ff0f654fb906db447b1993e4322cb71ab76e607 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 17 Oct 2022 14:29:05 +0200 Subject: [PATCH 2/2] daemon: add TEST_INTEGRATION_USE_SNAPSHOTTER for CI This allows us to run CI with the containerd snapshotter enabled, without patching the daemon.json, or changing how tests set up daemon flags. A warning log is added during startup, to inform if this variable is set, as it should only be used for our integration tests. Signed-off-by: Sebastiaan van Stijn --- Jenkinsfile | 5 +++++ Makefile | 1 + daemon/daemon.go | 7 +++++++ hack/make/.integration-test-helpers | 1 + 4 files changed, 14 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 772d43f45f..12c68d4b28 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -117,6 +117,7 @@ pipeline { -e DOCKER_GITCOMMIT=${GIT_COMMIT} \ -e DOCKER_GRAPHDRIVER \ -e TESTDEBUG \ + -e TEST_INTEGRATION_USE_SNAPSHOTTER \ -e TEST_SKIP_INTEGRATION_CLI \ -e TIMEOUT \ -e VALIDATE_REPO=${GIT_URL} \ @@ -203,6 +204,7 @@ pipeline { --name docker-pr$BUILD_NUMBER \ -e DOCKER_GITCOMMIT=${GIT_COMMIT} \ -e DOCKER_GRAPHDRIVER \ + -e TEST_INTEGRATION_USE_SNAPSHOTTER \ -e TEST_SKIP_INTEGRATION \ -e TIMEOUT \ -e VALIDATE_REPO=${GIT_URL} \ @@ -322,6 +324,7 @@ pipeline { -e DOCKER_GITCOMMIT=${GIT_COMMIT} \ -e DOCKER_GRAPHDRIVER \ -e TESTDEBUG \ + -e TEST_INTEGRATION_USE_SNAPSHOTTER \ -e TEST_SKIP_INTEGRATION_CLI \ -e TIMEOUT \ -e VALIDATE_REPO=${GIT_URL} \ @@ -415,6 +418,7 @@ pipeline { --name docker-pr$BUILD_NUMBER \ -e DOCKER_GITCOMMIT=${GIT_COMMIT} \ -e DOCKER_GRAPHDRIVER \ + -e TEST_INTEGRATION_USE_SNAPSHOTTER \ -e TEST_SKIP_INTEGRATION \ -e TIMEOUT \ -e VALIDATE_REPO=${GIT_URL} \ @@ -524,6 +528,7 @@ pipeline { -e DOCKER_GITCOMMIT=${GIT_COMMIT} \ -e DOCKER_GRAPHDRIVER \ -e TESTDEBUG \ + -e TEST_INTEGRATION_USE_SNAPSHOTTER \ -e TEST_SKIP_INTEGRATION_CLI \ -e TIMEOUT \ -e VALIDATE_REPO=${GIT_URL} \ diff --git a/Makefile b/Makefile index cfe3c17e4b..994d2d9f46 100644 --- a/Makefile +++ b/Makefile @@ -72,6 +72,7 @@ DOCKER_ENVS := \ -e GITHUB_ACTIONS \ -e TEST_FORCE_VALIDATE \ -e TEST_INTEGRATION_DIR \ + -e TEST_INTEGRATION_USE_SNAPSHOTTER \ -e TEST_SKIP_INTEGRATION \ -e TEST_SKIP_INTEGRATION_CLI \ -e TESTCOVERAGE \ diff --git a/daemon/daemon.go b/daemon/daemon.go index 1b4d86f840..67a413806e 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -142,6 +142,10 @@ func (daemon *Daemon) Features() *map[string]bool { // UsesSnapshotter returns true if feature flag to use containerd snapshotter is enabled func (daemon *Daemon) UsesSnapshotter() bool { + // TEST_INTEGRATION_USE_SNAPSHOTTER is used for integration tests only. + if os.Getenv("TEST_INTEGRATION_USE_SNAPSHOTTER") != "" { + return true + } if daemon.configStore.Features != nil { if b, ok := daemon.configStore.Features["containerd-snapshotter"]; ok { return b @@ -982,6 +986,9 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S } if d.UsesSnapshotter() { + if os.Getenv("TEST_INTEGRATION_USE_SNAPSHOTTER") != "" { + logrus.Warn("Enabling containerd snapshotter through the $TEST_INTEGRATION_USE_SNAPSHOTTER environment variable. This should only be used for testing.") + } logrus.Info("Starting daemon with containerd snapshotter integration enabled") // FIXME(thaJeztah): implement automatic snapshotter-selection similar to graph-driver selection; see https://github.com/moby/moby/issues/44076 diff --git a/hack/make/.integration-test-helpers b/hack/make/.integration-test-helpers index bbfc4edb86..b1c31b0b90 100644 --- a/hack/make/.integration-test-helpers +++ b/hack/make/.integration-test-helpers @@ -169,6 +169,7 @@ test_env() { PATH="$PATH" \ TEMP="$TEMP" \ TEST_CLIENT_BINARY="$TEST_CLIENT_BINARY" \ + TEST_INTEGRATION_USE_SNAPSHOTTER="$TEST_INTEGRATION_USE_SNAPSHOTTER" \ "$@" ) }