Skip to content

[24.0 backport] c8d/resolveImage: Fix Digested and Named reference#46013

Merged
thaJeztah merged 1 commit intomoby:24.0from
vvoland:c8d-resolve-fix-digested-and-named-24
Jul 18, 2023
Merged

[24.0 backport] c8d/resolveImage: Fix Digested and Named reference#46013
thaJeztah merged 1 commit intomoby:24.0from
vvoland:c8d-resolve-fix-digested-and-named-24

Conversation

@vvoland
Copy link
Contributor

@vvoland vvoland commented Jul 18, 2023

When resolving a reference that is both a Named and Digested, it could be resolved to an image that has the same digest, but completely different repository name.

(cherry picked from commit 3318736)

This caused a bunch of test failing with Error response from daemon: No such image: busybox:latest with the containerd integration enabled (#45232) because the testEnv.Clean deleted the source busybox image instead of the new tag created in test.

Example failing tests
=== FAIL: amd64.integration-cli TestDockerAPISuite/TestPostContainersCreateMemorySwappinessHostConfigOmitted (0.03s)
    docker_api_containers_test.go:1540: assertion failed: error is not nil: Error response from daemon: No such image: busybox:latest
    --- FAIL: TestDockerAPISuite/TestPostContainersCreateMemorySwappinessHostConfigOmitted (0.03s)

=== FAIL: amd64.integration-cli TestDockerAPISuite/TestPostContainersCreateShmSizeHostConfigOmitted (0.02s)
    docker_api_containers_test.go:1456: assertion failed: error is not nil: Error response from daemon: No such image: busybox:latest
    --- FAIL: TestDockerAPISuite/TestPostContainersCreateShmSizeHostConfigOmitted (0.02s)

=== FAIL: amd64.integration-cli TestDockerAPISuite/TestPostContainersCreateShmSizeOmitted (0.02s)
    docker_api_containers_test.go:1483: assertion failed: error is not nil: Error response from daemon: No such image: busybox:latest
    --- FAIL: TestDockerAPISuite/TestPostContainersCreateShmSizeOmitted (0.02s)

=== FAIL: amd64.integration-cli TestDockerAPISuite/TestPostContainersCreateWithShmSize (0.02s)
    docker_api_containers_test.go:1514: assertion failed: error is not nil: Error response from daemon: No such image: busybox:latest
    --- FAIL: TestDockerAPISuite/TestPostContainersCreateWithShmSize (0.02s)

- What I did
Fix digested and named reference being resolved to an image with different repository

- How I did it

- How to verify it
Test: TestRemoveByDigest

manually:

Before:

$ docker pull alpine
Using default tag: latest
82d1e9d7ed48: Download complete
e3bd82196e98: Download complete
5053b247d78b: Download complete
8c6d1654570f: Download complete
ndocker.io/library/alpine:latest
$ docker tag alpine asdf
$docker images
REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
alpine       latest    82d1e9d7ed48   4 seconds ago   11.7MB
asdf         latest    82d1e9d7ed48   2 seconds ago   11.7MB
$ docker rmi asdf@sha256:82d1e9d7ed48a7523bdebc18cf6290bdb97b82302a8a9c27d4fe885949ea94d1
Untagged: asdf@sha256:82d1e9d7ed48a7523bdebc18cf6290bdb97b82302a8a9c27d4fe885949ea94d1
$ docker images
REPOSITORY   TAG       IMAGE ID       CREATED          SIZE
asdf         latest    82d1e9d7ed48   15 seconds ago   11.7MB

After:

$ docker tag alpine asdf
$ docker images
REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
alpine       latest    82d1e9d7ed48   5 seconds ago   11.7MB
asdf         latest    82d1e9d7ed48   2 seconds ago   11.7MB
$ docker rmi asdf@sha256:82d1e9d7ed48a7523bdebc18cf6290bdb97b82302a8a9c27d4fe885949ea94d1
Untagged: asdf@sha256:82d1e9d7ed48a7523bdebc18cf6290bdb97b82302a8a9c27d4fe885949ea94d1
$ docker images
REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
alpine       latest    82d1e9d7ed48   9 seconds ago   11.7MB

- Description for the changelog

- Fix resolving a reference with repository name and digest to an image with a matching digest, but different repository.

- A picture of a cute animal (not mandatory but encouraged)

@vvoland vvoland added area/images Image Distribution kind/bugfix PR's that fix bugs containerd-integration Issues and PRs related to containerd integration labels Jul 18, 2023
@vvoland vvoland added this to the 24.0.5 milestone Jul 18, 2023
@vvoland vvoland force-pushed the c8d-resolve-fix-digested-and-named-24 branch from 82d4f2d to 6561a17 Compare July 18, 2023 15:53
When resolving a reference that is both a Named and Digested, it could
be resolved to an image that has the same digest, but completely
different repository name.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
(cherry picked from commit 48fc306)
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
@vvoland vvoland force-pushed the c8d-resolve-fix-digested-and-named-24 branch from 6561a17 to 3c5c192 Compare July 18, 2023 16:03
@thaJeztah thaJeztah changed the title [backport 24.0] c8d/resolveImage: Fix Digested and Named reference [24.0 backport] c8d/resolveImage: Fix Digested and Named reference Jul 18, 2023
Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@thaJeztah thaJeztah merged commit d4a26c1 into moby:24.0 Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/images Image Distribution containerd-integration Issues and PRs related to containerd integration kind/bugfix PR's that fix bugs

Projects

Development

Successfully merging this pull request may close these issues.

2 participants