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

Untag instead of force remove image for podman #1342

Merged
merged 1 commit into from
Mar 12, 2024

Conversation

TheRealHaoLiu
Copy link
Member

@TheRealHaoLiu TheRealHaoLiu commented Mar 6, 2024

⚠️ Warning: this PR will cause the behavior to deviate from name of the param --remove-images that runs this code ⚠️

This is a behavioral change (and hopefully for the better) now cleanup_images will behave the same for podman and docker

docker rmi will just untag while
podman rmi will untag and remove layers and cause runing container to be killed
for podman we use untag to achieve the same behavior

this only untag the image and does not delete the image prune_images need to be call to delete

@TheRealHaoLiu TheRealHaoLiu requested a review from a team as a code owner March 6, 2024 15:19
@TheRealHaoLiu TheRealHaoLiu marked this pull request as draft March 6, 2024 15:26

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
this is a behavioral change (and hopefully for the better)
now cleanup_images  will behave the same for podman and docker

NOTE: this PR will cause the behavior to deviate from the param `--remove-images` that runs this code
@TheRealHaoLiu TheRealHaoLiu marked this pull request as ready for review March 6, 2024 16:12
@nitzmahone
Copy link
Member

I get why people want builder to do rmi (though still ill-advised), but why is runner managing images at all? At least under modern podman, just running container instances shouldn't be creating new images.

@TheRealHaoLiu TheRealHaoLiu changed the title Untag instead of force remove image for podman - the simple version Untag instead of force remove image for podman Mar 6, 2024
@shanemcd
Copy link
Member

shanemcd commented Mar 6, 2024

@nitzmahone I was asking myself the same thing. I think it was added to ansible-runner because that's the only thing other than receptor we install on execution nodes, which is where we need to run this.

@AlanCoding
Copy link
Member

My 2 cents - runner is effectively acting as a command allow-list here. If we could ship an arbitrary python file or bash script, it could be done that way, but perhaps, less securely. In the receptor mesh, the control nodes are only allowed to run ansible-runner worker commands. So we have to go through ansible-runner for anything AWX needs to run.

TheRealHaoLiu added a commit to TheRealHaoLiu/awx that referenced this pull request Mar 6, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
pairs with ansible/ansible-runner#1342

this fix the problem of us forcefully remove images when setting changing ee image that's being used in a job causing the job to fail
if runtime == 'podman':
try:
stdout = run_command([runtime, 'untag', image_tag])
if not stdout:
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't get it. Why are we incrementing the count if there is no output?

Copy link
Member Author

Choose a reason for hiding this comment

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

that's what podman does... it doesn't output anything when u run podman untag it will however output an error if it fail to untag

Copy link
Contributor

Choose a reason for hiding this comment

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

Why do the condition at all, then? Rely on the logic getting derailed by the exception.

Copy link

Choose a reason for hiding this comment

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

agree with @jbradberry lets keep it simple

Copy link
Member Author

Choose a reason for hiding this comment

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

it shouldn't be needed but it is possible, since this is best effort and not "critical" i rather the behavior to be move on instead of bail

Copy link
Contributor

Choose a reason for hiding this comment

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

How about we get this merged as-in and do an ansible-runner release. Then we can can create a tech-debt task to follow up on this.

Copy link
Contributor

Choose a reason for hiding this comment

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

@gundalow going to have to push back against that. It's basically a one-line change, and if it's worth doing at all it should be done up-front. If it merges as-is, it more or less means that we don't care about the possibility of podman's behavior changing and a follow-up task would just sink out of sight.

Copy link
Contributor

Choose a reason for hiding this comment

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

(I'm not opposed to merging as-is, but we shouldn't fool ourselves that we'll ever address such a minor concern unless it bites us in the future.)

@gundalow gundalow requested review from jimi-c, sivel and Shrews March 8, 2024 12:53
Copy link

@chadmf chadmf left a comment

Choose a reason for hiding this comment

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

LGTM!

@Shrews Shrews merged commit d51a2f3 into ansible:devel Mar 12, 2024
12 checks passed
Shrews pushed a commit to Shrews/ansible-runner that referenced this pull request Mar 12, 2024
now cleanup_images will behave the same for podman and docker

(cherry picked from commit d51a2f3)
Shrews added a commit that referenced this pull request Mar 12, 2024
now cleanup_images will behave the same for podman and docker

(cherry picked from commit d51a2f3)

Co-authored-by: Hao Liu <[email protected]>
TheRealHaoLiu added a commit to ansible/awx that referenced this pull request Mar 12, 2024
Prune dangle image periodically

pairs with ansible/ansible-runner#1342

this fix the problem of us forcefully remove images when setting changing ee image that's being used in a job causing the job to fail
@TheRealHaoLiu TheRealHaoLiu deleted the podman-untag branch March 12, 2024 16:17
djyasin pushed a commit to djyasin/awx that referenced this pull request Sep 16, 2024
Prune dangle image periodically

pairs with ansible/ansible-runner#1342

this fix the problem of us forcefully remove images when setting changing ee image that's being used in a job causing the job to fail
djyasin pushed a commit to djyasin/awx that referenced this pull request Nov 11, 2024
Prune dangle image periodically

pairs with ansible/ansible-runner#1342

this fix the problem of us forcefully remove images when setting changing ee image that's being used in a job causing the job to fail
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.

None yet

9 participants