Skip to content

[27.x backport] c8d/prune: Keep the last tagged image instead of creating dangling image#48488

Merged
thaJeztah merged 4 commits intomoby:27.xfrom
thaJeztah:27.x_backport_c8d-prune-keeplastref
Sep 12, 2024
Merged

[27.x backport] c8d/prune: Keep the last tagged image instead of creating dangling image#48488
thaJeztah merged 4 commits intomoby:27.xfrom
thaJeztah:27.x_backport_c8d-prune-keeplastref

Conversation

@thaJeztah
Copy link
Member

Don't turn images into dangling when they are used by containers created with an image specified by an ID only (e.g. docker run 82d1e9d).

Keep the last image reference with the same target when all other references would be pruned.

If the container was created with a digested and tagged reference (e.g. docker run alpine:latest@sha256:82d1e9d7ed48a7523bdebc18cf6290bdb97b82302a8a9c27d4fe885949ea94d1), the alpine:latest image won't get untagged.

This change makes the behavior consistent with the graphdriver implementation.

- What I did

- How I did it

- How to verify it
TestPruneDontDeleteUsedImage

- Description for the changelog

containerd integration: Fix `docker image prune -a` untagging images used by containers started from images referenced by a digested reference.

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

Don't turn images into dangling when they are used by containers created
with an image specified by an ID only (e.g. `docker run 82d1e9d`).

Keep the last image reference with the same target when all other
references would be pruned.

If the container was created with a digested and tagged reference (e.g.
`docker run alpine:latest@sha256:82d1e9d7ed48a7523bdebc18cf6290bdb97b82302a8a9c27d4fe885949ea94d1`),
the `alpine:latest` image won't get untagged.

This change makes the behavior consistent with the graphdriver
implementation.

Signed-off-by: Paweł Gronowski <[email protected]>
(cherry picked from commit e4c2eb9)
Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah thaJeztah added status/2-code-review impact/changelog area/images Image Distribution kind/bugfix PR's that fix bugs containerd-integration Issues and PRs related to containerd integration labels Sep 12, 2024
@thaJeztah thaJeztah added this to the 27.3.0 milestone Sep 12, 2024
@thaJeztah thaJeztah self-assigned this Sep 12, 2024
@thaJeztah
Copy link
Member Author

I'm missing a utility from another PR;

integration/image/prune_test.go:147:45: undefined: image.InspectResponse
integration/image/prune_test.go:151:47: undefined: image.InspectResponse
integration/image/prune_test.go:157:47: undefined: image.InspectResponse
integration/image/prune_test.go:163:47: undefined: image.InspectResponse
integration/image/prune_test.go:169:47: undefined: image.InspectResponse
integration/image/prune_test.go:177:47: undefined: image.InspectResponse
integration/image/prune_test.go:185:47: undefined: image.InspectResponse

@thaJeztah thaJeztah marked this pull request as draft September 12, 2024 18:46
@thaJeztah
Copy link
Member Author

hm.. right, so we need 7053007, which is part of;

thaJeztah and others added 3 commits September 12, 2024 21:45
The 27.x branch does not have 7053007
adjusting the test to use the old location.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
Signed-off-by: Paweł Gronowski <[email protected]>
(cherry picked from commit 23e79a2)
Signed-off-by: Sebastiaan van Stijn <[email protected]>
When untagging multiple images targetting the same digest, delete the
images in lexographic order to be consistent with graphdrivers.

Signed-off-by: Paweł Gronowski <[email protected]>
(cherry picked from commit fefa98a)
Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah thaJeztah force-pushed the 27.x_backport_c8d-prune-keeplastref branch from 6f568c9 to b262a95 Compare September 12, 2024 19:46
@thaJeztah
Copy link
Member Author

The image.InspectResponse was only used in the test; I adjusted the test to make it work for this branch, but kept that in a separate commit

@thaJeztah thaJeztah marked this pull request as ready for review September 12, 2024 20:09
@thaJeztah thaJeztah merged commit bf60e5c into moby:27.x Sep 12, 2024
@thaJeztah thaJeztah deleted the 27.x_backport_c8d-prune-keeplastref branch September 12, 2024 21:34
renovate bot added a commit to earthly/dind that referenced this pull request Sep 23, 2024
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [docker/docker](https://redirect.github.com/docker/docker) | minor |
`27.2.1` -> `27.3.1` |

---

### Release Notes

<details>
<summary>docker/docker (docker/docker)</summary>

###
[`v27.3.1`](https://redirect.github.com/moby/moby/releases/tag/v27.3.1)

[Compare
Source](https://redirect.github.com/docker/docker/compare/v27.3.0-rc.1...v27.3.1)

#### 27.3.1

For a full list of pull requests and changes in this release, refer to
the relevant GitHub milestones:

- [docker/cli, 27.3.1
milestone](https://redirect.github.com/docker/cli/issues?q=sort%3Aupdated-desc+is%3Aclosed+milestone%3A27.3.1)
- [moby/moby, 27.3.1
milestone](https://redirect.github.com/moby/moby/issues?q=sort%3Aupdated-desc+is%3Aclosed+milestone%3A27.3.1)

##### Bug fixes and enhancements

- CLI: Fix issue with command execution metrics not being exported due
to the CLI MeterProvider being shutdown too early.
[docker/cli#5457](https://redirect.github.com/docker/cli/pull/5457)

##### Packaging updates

- Update `Compose` to
[v2.29.7](https://redirect.github.com/docker/compose/releases/tag/v2.29.7)

###
[`v27.3.0`](https://redirect.github.com/moby/moby/releases/tag/v27.3.0)

[Compare
Source](https://redirect.github.com/docker/docker/compare/v27.2.1...v27.3.0-rc.1)

#### 27.3.0

For a full list of pull requests and changes in this release, refer to
the relevant GitHub milestones:

- [docker/cli, 27.3.0
milestone](https://redirect.github.com/docker/cli/issues?q=sort%3Aupdated-desc+is%3Aclosed+milestone%3A27.3.0)
- [moby/moby, 27.3.0
milestone](https://redirect.github.com/moby/moby/issues?q=sort%3Aupdated-desc+is%3Aclosed+milestone%3A27.3.0)

##### Bug fixes and enhancements

- containerd image store: Fix `docker image prune -a` untagging images
used by containers started from images referenced by a digested
reference.
[moby/moby#48488](https://redirect.github.com/moby/moby/pull/48488)
- Add a `--feature` flag to the daemon options.
[moby/moby#48487](https://redirect.github.com/moby/moby/pull/48487)
- Updated the handling of the `--gpus=0` flag to be consistent with the
NVIDIA Container Runtime.
[moby/moby#48483](https://redirect.github.com/moby/moby/pull/48483)

[https://github.com/docker/cli/pull/5432](https://redirect.github.com/docker/cli/pull/5432)5432)
- Support WSL2 mirrored-mode networking's use of interface `loopback0`
for packets from the Windows host.
[moby/moby#48514](https://redirect.github.com/moby/moby/pull/48514)
- Fix an issue that prevented communication between containers on an
IPv4 bridge network when running with `--iptables=false`,
`--ip6tables=true` (the default), a firewall with a DROP rule for
forwarded packets on hosts where the `br_netfilter` kernel module was
not normally loaded.
[moby/moby#48511](https://redirect.github.com/moby/moby/pull/48511)
- CLI: Fix issue where `docker volume update` command would cause the
CLI to panic if no argument/volume was passed.
[docker/cli#5426](https://redirect.github.com/docker/cli/pull/5426)
- CLI: Properly report metrics when run in WSL environment on Windows.
\[[docker/cli#5432](https://redirect.github.com/docker/cli/issues/5432)]

##### Packaging updates

- Update `containerd` (static binaries only) to
[v1.7.22](https://redirect.github.com/containerd/containerd/releases/tag/v1.7.22)
    [moby/moby#48468](https://redirect.github.com/moby/moby/pull/48468)
- Updated `Buildkit` to
[v0.16.0](https://redirect.github.com/moby/buildkit/releases/tag/v0.16.0)
- Update `Compose` to
[v2.29.6](https://redirect.github.com/docker/compose/releases/tag/v2.29.6)
- Update `Buildx` to
[v0.17.1](https://redirect.github.com/docker/buildx/releases/tag/v0.17.1)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "after 6am on monday" (UTC), Automerge
- At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/earthly/dind).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC44MC4wIiwidXBkYXRlZEluVmVyIjoiMzguODAuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsicmVub3ZhdGUiXX0=-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
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 impact/changelog kind/bugfix PR's that fix bugs status/2-code-review

Projects

Development

Successfully merging this pull request may close these issues.

3 participants