Skip to content

Add RunOptions.ValidExitCodes and --valid-exit-codes flag#6817

Open
akca wants to merge 4 commits intocontainers:mainfrom
akca:opexec-validexitcodes
Open

Add RunOptions.ValidExitCodes and --valid-exit-codes flag#6817
akca wants to merge 4 commits intocontainers:mainfrom
akca:opexec-validexitcodes

Conversation

@akca
Copy link
Copy Markdown
Contributor

@akca akca commented Apr 28, 2026

What type of PR is this?

/kind feature

What this PR does / why we need it:

Adds a new field RunOptions.ValidExitCodes and a --valid-exit-codes CLI flag for buildah run that lets specific non-zero exit codes be treated as success, aligning with BuildKit's Op_Exec.Meta.ValidExitCodes.

How to verify it

go test -run TestCheckExitCodeError -v .
bats tests/run.bats -f "run-valid-exit-codes"

Which issue(s) this PR fixes:

Fixes #6805

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Added `--valid-exit-codes` flag for `buildah run` to accept specific non-zero exit codes as success.

@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Apr 28, 2026
Add support for treating specific non-zero exit codes as success in `buildah run`, aligning with BuildKit's Op_Exec.Meta.ValidExitCodes semantics.

Signed-off-by: Fatih Akca <fatihakca5@gmail.com>
@akca akca force-pushed the opexec-validexitcodes branch from ec415bc to 70db65d Compare April 28, 2026 16:10
Comment thread docs/buildah-run.1.md
Comment thread tests/run.bats
run_buildah 1 run $cid sh -c "exit 1"

# Exit 1 succeeds with --valid-exit-codes 0,1
run_buildah run --valid-exit-codes 0,1 $cid sh -c "exit 1"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can you add a verification that you got the right error on this call?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, just added

@TomSweeneyRedHat
Copy link
Copy Markdown
Member

In general, LGTM
I restarted what looked to be a flaking test.
@nalind WDYT?

akca added 2 commits April 29, 2026 11:33
Signed-off-by: Fatih Akca <fatihakca5@gmail.com>
Signed-off-by: Fatih Akca <fatihakca5@gmail.com>
@akca akca requested a review from TomSweeneyRedHat April 29, 2026 10:48
chroot isolation path prints "subprocess exited with status 1" unconditionally, so the output is never empty even on success.

Signed-off-by: Fatih Akca <fatihakca5@gmail.com>
@akca akca force-pushed the opexec-validexitcodes branch from 05048b2 to 5b2c4c4 Compare April 29, 2026 16:55
@packit-as-a-service
Copy link
Copy Markdown

Ephemeral COPR build failed. @containers/packit-build please check.

Copy link
Copy Markdown
Member

@nalind nalind left a comment

Choose a reason for hiding this comment

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

LGTM, thanks! Please squash these before merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for Op_Exec.Meta.ValidExitCodes

3 participants