From d98c41ba07de28078b7b511bf124549f97a13f4d Mon Sep 17 00:00:00 2001 From: Guillaume Lours Date: Thu, 6 Aug 2026 15:42:26 +0200 Subject: [PATCH] ci(e2e): run e2e against the containerd image store MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The e2e suite only ran on graphdriver daemons, where the different kinds of image digests coincide — the blind spot that let #13636, #13998 and #14005 through. Add one matrix entry enabling the containerd image store, plus TestUpIdempotentContainerdStore: two consecutive `up` runs with no change must not recreate any container. The test is red on this configuration (the com.docker.compose.image label is written from the index digest on the pulling run, then compared against the per-platform manifest digest on the next run) and skipped until the next commit resolves the pull-path digest. Signed-off-by: Guillaume Lours --- .github/workflows/ci.yml | 29 ++++++- pkg/e2e/fixtures/image-identity/compose.yaml | 4 + pkg/e2e/image_identity_test.go | 81 ++++++++++++++++++++ 3 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 pkg/e2e/fixtures/image-identity/compose.yaml create mode 100644 pkg/e2e/image_identity_test.go diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 78f5c5ef5..7f55b3aee 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -165,7 +165,7 @@ jobs: e2e: runs-on: ubuntu-latest - name: e2e (${{ matrix.mode }}, ${{ matrix.channel }}) + name: e2e (${{ matrix.mode }}, ${{ matrix.channel }}${{ matrix.store && format(', {0}', matrix.store) || '' }}) strategy: fail-fast: false matrix: @@ -185,12 +185,23 @@ jobs: - mode: standalone engine: 28 channel: oldstable + + # containerd image store (non-graphdriver digest behavior) + - mode: plugin + engine: 29 + channel: stable + store: containerd steps: - name: Prepare run: | mode=${{ matrix.mode }} engine=${{ matrix.engine }} - echo "MODE_ENGINE_PAIR=${mode}-${engine}" >> $GITHUB_ENV + store=${{ matrix.store }} + pair="${mode}-${engine}" + if [ -n "$store" ]; then + pair="${pair}-${store}" + fi + echo "MODE_ENGINE_PAIR=${pair}" >> $GITHUB_ENV - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -206,6 +217,20 @@ jobs: - name: Check Docker Version run: docker --version + - name: Enable containerd image store + if: ${{ matrix.store == 'containerd' }} + run: | + sudo mkdir -p /etc/docker + if [ -s /etc/docker/daemon.json ]; then + jq -s '.[0] * .[1]' /etc/docker/daemon.json <(echo '{"features": {"containerd-snapshotter": true}}') \ + | sudo tee /etc/docker/daemon.json.new > /dev/null + sudo mv /etc/docker/daemon.json.new /etc/docker/daemon.json + else + echo '{"features": {"containerd-snapshotter": true}}' | sudo tee /etc/docker/daemon.json > /dev/null + fi + sudo systemctl restart docker.service + docker info -f '{{json .DriverStatus}}' | grep -q io.containerd.snapshotter.v1 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0 diff --git a/pkg/e2e/fixtures/image-identity/compose.yaml b/pkg/e2e/fixtures/image-identity/compose.yaml new file mode 100644 index 000000000..11a73d4fd --- /dev/null +++ b/pkg/e2e/fixtures/image-identity/compose.yaml @@ -0,0 +1,4 @@ +services: + app: + image: alpine:3.20 + command: ["sleep", "infinity"] diff --git a/pkg/e2e/image_identity_test.go b/pkg/e2e/image_identity_test.go new file mode 100644 index 000000000..bf7dc897a --- /dev/null +++ b/pkg/e2e/image_identity_test.go @@ -0,0 +1,81 @@ +/* + Copyright 2020 Docker Compose CLI authors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package e2e + +import ( + "fmt" + "strings" + "testing" + + "gotest.tools/v3/assert" +) + +// TestUpIdempotentContainerdStore reproduces the scenario described in +// https://github.com/docker/compose/pull/13998 : under the containerd image +// store, a multi-platform image pulled by the first `up` gets its +// `com.docker.compose.image` label set from the raw digest returned by +// `image inspect` (the manifest-list/index digest). On the next `up`, the +// image is now local, so compose recomputes the label from the per-platform +// manifest digest instead. Those two digests differ for the very same image, +// so compose believes the image changed and recreates the container even +// though nothing did. +// +// `up` MUST be idempotent: running it twice in a row without any change +// must not recreate any container. +func TestUpIdempotentContainerdStore(t *testing.T) { + // TODO(image-identity): temporary skip — this test is red by design until + // the canonical content-digest producer lands (next commit of this PR). + // Remove this skip in that commit; the test is the acceptance criterion. + t.Skip("skipped until the canonical image content-digest producer lands (see PR commits)") + + c := NewCLI(t) + requireContainerdStore(t, c) + + const projectName = "compose-e2e-image-identity-idempotent" + const image = "alpine:3.20" + const composeFile = "./fixtures/image-identity/compose.yaml" + + t.Cleanup(func() { + c.cleanupWithDown(t, projectName) + c.RunDockerOrExitError(t, "rmi", "-f", image) + }) + + // Start from an image that was never pulled locally: the first `up` + // below will pull it, exercising the multi-platform pull path. + c.RunDockerOrExitError(t, "rmi", "-f", image) + + c.RunDockerComposeCmd(t, "-f", composeFile, "--project-name", projectName, "up", "-d") + containerID := c.RunDockerCmd(t, "inspect", fmt.Sprintf("%s-app-1", projectName), "-f", "{{.Id}}").Stdout() + + res := c.RunDockerComposeCmd(t, "-f", composeFile, "--project-name", projectName, "up", "-d") + assert.Check(t, !strings.Contains(res.Combined(), "Recreate"), "second `up` should not recreate anything, got: %s", res.Combined()) + + newContainerID := c.RunDockerCmd(t, "inspect", fmt.Sprintf("%s-app-1", projectName), "-f", "{{.Id}}").Stdout() + assert.Equal(t, containerID, newContainerID, "container should not have been recreated by an idempotent `up`") +} + +// requireContainerdStore skips the test unless the docker daemon backing the +// CLI instance uses the containerd image store (`io.containerd.snapshotter.v1` +// driver), which is a prerequisite for the image identity bug this test +// covers. +func requireContainerdStore(t *testing.T, c *CLI) { + t.Helper() + res := c.RunDockerCmd(t, "info", "-f", "{{json .DriverStatus}}") + if !strings.Contains(res.Stdout(), "io.containerd.snapshotter.v1") { + t.Skip("Skipping test: daemon is not using the containerd image store") + } +}