Skip to content

Adding dry run option in Image.removeRecursive#843

Open
zvenigorodsky wants to merge 1 commit into
containers:mainfrom
zvenigorodsky:27838
Open

Adding dry run option in Image.removeRecursive#843
zvenigorodsky wants to merge 1 commit into
containers:mainfrom
zvenigorodsky:27838

Conversation

@zvenigorodsky
Copy link
Copy Markdown

Partially resolving: containers/podman#27838

There's no consideration for the ignore option currently, this way we preserve current behavior and add the option

Copy link
Copy Markdown
Contributor

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

Thanks!

I don’t see any documented relationship between the Ignore option and a “dry run” feature; after this PR, there is no reason for a dry-run implementation to use the Ignore option; and there is no reason for a caller of Ignore to expect that removals wouldn’t happen.

And apart from the conceptual semantics, it doesn’t even work for the intended purpose anyway: Untag calls would still happen.

@zvenigorodsky
Copy link
Copy Markdown
Author

Thanks!

I don’t see any documented relationship between the Ignore option and a “dry run” feature; after this PR, there is no reason for a dry-run implementation to use the Ignore option; and there is no reason for a caller of Ignore to expect that removals wouldn’t happen.

And apart from the conceptual semantics, it doesn’t even work for the intended purpose anyway: Untag calls would still happen.

Should I add another option for dry run in RemoveImageOptions? I see that there's a noPrune option but the documentation says it's only for dangling images, and about the untag I'll make changes to address that

@mtrmac
Copy link
Copy Markdown
Contributor

mtrmac commented May 13, 2026

I think you’ll also find that the current iterative logic for detecting / handling dangling images and parents does expect the removals to actually happen. So this would be a fairly major restructuring of code that claims itself to be “complex”.

@zvenigorodsky zvenigorodsky marked this pull request as draft May 13, 2026 20:41
@zvenigorodsky zvenigorodsky marked this pull request as ready for review May 14, 2026 13:25
Copy link
Copy Markdown
Contributor

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

I think you’ll also find that the current iterative logic for detecting / handling dangling images and parents does expect the removals to actually happen.

@zvenigorodsky
Copy link
Copy Markdown
Author

I think you’ll also find that the current iterative logic for detecting / handling dangling images and parents does expect the removals to actually happen.

It does expect the removals to happen but from what I saw it mainly looks at the rmMap entries and the report.Removed property, which the dry run option doesn't touch.

The only calls in removeRecursive are Untag, removeContainerss and DeleteImage and we skip those calls

@zvenigorodsky zvenigorodsky requested a review from mtrmac May 14, 2026 17:53
Copy link
Copy Markdown
Contributor

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

For a start, the danglingParent, err := parent.IsDangling(ctx) logic would be broken.

I’m not very familiar with this code and I didn’t look much further.

We can’t have a --dry-run option that under-reports its actions.

@zvenigorodsky zvenigorodsky changed the title Added consideration for ignore option in removeImage Adding dry run option in removeRecursive May 15, 2026
@zvenigorodsky zvenigorodsky changed the title Adding dry run option in removeRecursive Adding dry run option in Image.removeRecursive May 15, 2026
@zvenigorodsky
Copy link
Copy Markdown
Author

For a start, the danglingParent, err := parent.IsDangling(ctx) logic would be broken.

I’m not very familiar with this code and I didn’t look much further.

We can’t have a --dry-run option that under-reports its actions.

How would it break it? if it will find a dangling parent it will run with the same options and rmMap

Would you rather I make a dedicated method for removeRecursive dry run?

@mtrmac
Copy link
Copy Markdown
Contributor

mtrmac commented May 15, 2026

In dry-run, the parent would never be dangling; after a real removal, it could.

I have no opinion on a good implementation here (and, sadly, no time to design one now — perhaps other maintainers can chime in).

Signed-off-by: Mark Zvenigorodsky <mark.zvenigorodsky@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

common Related to "common" package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants