Skip to content

fix: do not create networks and volumes with --dry-run - #1528

Open
Sanjays2402 wants to merge 2 commits into
containers:mainfrom
Sanjays2402:fix/dry-run-no-network-volume-creation
Open

fix: do not create networks and volumes with --dry-run#1528
Sanjays2402 wants to merge 2 commits into
containers:mainfrom
Sanjays2402:fix/dry-run-no-network-volume-creation

Conversation

@Sanjays2402

Copy link
Copy Markdown

Closes #1440

Contributor Checklist:

Podman.run() honors dry_run and only logs the command, but Podman.output() always spawns the process. assert_volume() and assert_cnt_nets() create through output(), so podman-compose --dry-run up really created every referenced network and volume. Both now log the create command and skip it under --dry-run, matching what run() already does for the create/start calls.

Compose spec reference for --dry-run: https://docs.docker.com/reference/cli/docker/compose/#options

Unit tests added in tests/unit/test_dry_run.py: they assert that under dry_run the only podman calls issued are the existence probes (volume inspect / network exists) and never a create. Both fail on current main and pass with this change; the full tests/unit suite is green (469 passed), and ruff check/ruff format are clean on both changed files.

I did not add a newsfragments/ entry because I wasn't sure whether this counts as user-visible enough to warrant one — happy to add newsfragments/dry_run_no_side_effects.bugfix if you'd like it.

This change was prepared with AI assistance; the regression tests were run locally and fail without the fix.

Podman.run() honors dry_run and only logs the command, but Podman.output()
always spawns the process. assert_volume() and assert_cnt_nets() use
output(), so 'podman-compose --dry-run up' really created every referenced
network and volume, violating the semantics of --dry-run.

Both now log the create command and skip it when dry_run is set, matching
what Podman.run() already does for the create/start calls.

Adds tests/unit/test_dry_run.py asserting that no create call is issued.

@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.

Looks great, thanks. Please add a release note.

@Sanjays2402

Copy link
Copy Markdown
Author

Added in 53674d0: newsfragments/dry_run_no_network_volume_creation.bugfix, typed as a bugfix since the old behaviour actually created networks and volumes on a dry run.

469 unit tests still pass.

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.

Networks and volumes are created when --dry-run is passed

2 participants