Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testutil: fix make_container() cleanup #1757

Merged
merged 1 commit into from
Apr 25, 2024

Conversation

mvo5
Copy link
Contributor

@mvo5 mvo5 commented Apr 25, 2024

During the work on PR#1752 Florian discovered that make_containers() is broken for nested containers like:

with make_container(tmp_path, {"file1": "file1 from base"}) as base_tag:
    with make_container(tmp_path, {"file1": "file1 from final layer"}, base_tag) as cont_tag:

It errors with:

Error: 5b947de461ee21b858dd5b4224e80442b2f65b6410189147f2445884d9e4e3d8: image not known

The reason is that we work with hashes for the image and then call podman image rm which by default will also remove all dangling references. Those are defined by not having a tag and not referenced anymore. So the inner container cleanup also removes the outter.

There are many ways to fix this, I went with re-adding tags to the test containers because it also makes it easy for the user to see if we left any containers (accidently) around.

[this (or a variant thereof) is needed before we can merge https://github.com/osbuild/containers/pull/72]

@mvo5 mvo5 requested a review from achilleas-k April 25, 2024 11:15
During the work on PR#1752 Florian discovered that make_containers()
is broken for nested containers like:
```
with make_container(tmp_path, {"file1": "file1 from base"}) as base_tag:
    with make_container(tmp_path, {"file1": "file1 from final layer"}, base_tag) as cont_tag:
```
It errors with:
```
Error: 5b947de461ee21b858dd5b4224e80442b2f65b6410189147f2445884d9e4e3d8: image not known
```
The reason is that we work with hashes for the image and then call
`podman image rm` which by default will also remove all dangling
references. Those are defined by not having a tag and not referenced
anymore. So the inner container cleanup also removes the outter.

There are many ways to fix this, I went with re-adding tags to the
test containers because it also makes it easy for the user to see if
we left any containers (accidently) around.
@mvo5 mvo5 force-pushed the fix-make-container-dandling-rm branch from 8b854ca to c51b705 Compare April 25, 2024 11:27
Copy link
Contributor

@bcl bcl left a comment

Choose a reason for hiding this comment

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

Nice!

@mvo5 mvo5 merged commit a3f86a0 into osbuild:main Apr 25, 2024
44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants