Skip to content

Fix orphan removal: use getattr#1387

Open
benrogmans wants to merge 1 commit into
containers:mainfrom
benrogmans:patch-1
Open

Fix orphan removal: use getattr#1387
benrogmans wants to merge 1 commit into
containers:mainfrom
benrogmans:patch-1

Conversation

@benrogmans

Copy link
Copy Markdown

When exiting podman compose by repeating ctrl+C rapidly, its state may get corrupt and no longer have the remove_orphans attribute. This broke podman compose for me.

Contributor Checklist:

If this PR adds a new feature that improves compatibility with docker-compose, please add a link
to the exact part of compose spec that the PR touches.

For any user-visible change please add a release note to newsfragments directory, e.g.
newsfragments/my_feature.feature. See newsfragments/README.md for more details.

All changes require additional unit tests.

When exiting podman compose by repeating ctrl+C rapidly, its state may get corrupt and no longer have the remove_orphans attribute. This broke podman compose for me.
Copilot AI review requested due to automatic review settings February 2, 2026 17:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Makes podman compose down resilient to a corrupted/partial argparse.Namespace by avoiding an AttributeError when remove_orphans is missing (reported when repeatedly hitting Ctrl+C during exit).

Changes:

  • Switch args.remove_orphans access to getattr(args, "remove_orphans", False) in compose_down.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread podman_compose.py

orphaned_images = set()
if args.remove_orphans:
if getattr(args, 'remove_orphans', False):

Copilot AI Feb 2, 2026

Copy link

Choose a reason for hiding this comment

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

Use double quotes for consistency with the rest of this file’s getattr(args, ...) calls (e.g., getattr(args, "timeout", None) a few lines above).

Copilot uses AI. Check for mistakes.
Comment thread podman_compose.py

orphaned_images = set()
if args.remove_orphans:
if getattr(args, 'remove_orphans', False):

Copilot AI Feb 2, 2026

Copy link

Choose a reason for hiding this comment

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

Add test coverage for this regression: compose_down should not raise when args is missing remove_orphans (e.g., an argparse.Namespace constructed without that attribute). This change is user-facing and there are existing unit/integration tests for down, but none cover the missing-attribute scenario.

Copilot uses AI. Check for mistakes.
@p12tic

p12tic commented Feb 21, 2026

Copy link
Copy Markdown
Collaborator

Without exact reproduction steps I cannot merge this PR. It's not possible to verify that the issue actually happens and that this PR fixes it.

@p12tic p12tic left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Without exact reproduction steps I cannot merge this PR. It's not possible to verify that the issue actually happens and that this PR fixes it.

@benrogmans

Copy link
Copy Markdown
Author

I can't reproduce it either as the interrupt needs to be timed precisely... but it is a state that can occur.

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