c8d/prune: Fix images being deleted when they're still used with a different reference#45839
Conversation
|
Looks like there's a failure; |
|
I'm wondering though; if 2 images are tags for the same digest, wouldn't we have to use the reverse? Untag the image, and let containerd prune / garbage collect unused content? (If we use "force", them probably we must change the tag name to a dangling image name instead) |
|
(I'm not sure if that would still provide us a way to report the amount of space we reclaimed though) |
|
Discussing with @neersighted and we were considering if we should take a different approach in general;
Now when we remove an image; we either remove the image's So instead of creating dangling image references "on the fly", we can create them up-front, and use them for reference counting on our side |
577f7c1 to
1d6d432
Compare
|
Ah, the failure is on Windows only, because the
I thought about it before, but it seemed to be a bit more tricky because the image creation is not always on our side (for example building image with Buildkit) whereas it's more common for Moby to perform image deletion. On the other hand, that would indeed give us more control over the GC and would make more sense in cases where an explicit image digest is used instead of a name (so for example We could give it a try and see if that doesn't complicate things too much. It's a bit orthogonal to this PR though, so possibly we should just fix this issue here and then continue in a follow-up/separate ticket.
Yes, this will cause the unused tag which also points to the same target as the used tag. Also, there's another unsolved issue - images referenced by their id ( Fixed it now. |
neersighted
left a comment
There was a problem hiding this comment.
Some initial nits, though I'm not a fan of how imperative this code is, and I think I might send a PR to your branch with a restructured implementation that keeps each category of prune exclusion more discrete.
1d6d432 to
c9d8569
Compare
neersighted
left a comment
There was a problem hiding this comment.
One nit, but overall LGTM. I think that we should restructure this logic in the future, but I think that we can take this as an improvement for now, and think about lifecycle management more holistically in the future (during which we can revisit this logic, and perhaps even generalize it).
c9d8569 to
edbfecb
Compare
thaJeztah
left a comment
There was a problem hiding this comment.
LGTM (but let me know if you want to address that nit; not a blocker)
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
So we don't override the original Labels in the passed image object. Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
If an image is only by id instead of its name, don't prune it completely. but only untag it and create a dangling image for it. Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
edbfecb to
e638351
Compare
|
Backported at #45857 |
|
@neersighted commits still align? I see there may be a potential race condition between you cherry-picking and Pawel force-pushing 😓 🙈 |
|
That's one of the things to check when reviewing a backport PR 😉 But yes, I made sure to re-cherry (with rerere) once Pawel pushed again; all SHAs are aligned to the latest version of this PR. |
|
Thanks! |
|
Timeout in one of the BuildKit tests (panic: test timed out after 30m0s); kicked it again |
- What I did
Fixed
image prune -adeleting dangling images used by containers.- How I did it
- How to verify it
$ make TEST_INTEGRATION_USE_SNAPSHOTTER=1 \ DOCKER_GRAPHDRIVER=overlayfs \ TEST_FILTER=TestPruneDontDeleteUsedDangling \ test-integration ... INFO: Testing against a local daemon === RUN TestPruneDontDeleteUsedDangling --- PASS: TestPruneDontDeleteUsedDangling (0.07s) PASS DONE 1 tests in 1.079s- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)