Exit non-zero from batch mode when no minions match#69749
Open
ggiesen wants to merge 1 commit into
Open
Conversation
In batch mode the salt CLI computed its exit code by iterating batch.run(),
which yields nothing when the target matches no minions (Batch.run returns
early on an empty minion list). retcode stayed 0 and the CLI exited 0, while
the non-batch path exits 2 ("No return received") for the same case
(saltstack#57357). Mirror the non-batch behavior: when no minions matched, print
"No return received" and exit 2.
Fixes saltstack#57357
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Makes the
saltCLI exit 2 ("No return received") in batch mode when the target matches no minions, matching the non-batch behavior instead of silently exiting 0.What issues does this PR fix or reference?
Fixes #57357
Previous Behavior
In batch mode the CLI's exit code was derived by iterating
batch.run(). When the target matches no minions,Batch.run()returns early on an empty minion list and yields nothing, so the loop never runs,retcodestays 0, and the CLI exits 0. The non-batch path instead reaches the "No return received" guard in_output_retand exits 2, so the two modes disagree on a no-match run.New Behavior
After the batch loop, if no minions matched (
batch.minionsis empty), the CLI prints "No return received" and exits 2, matching non-batch. The--staticbatch branch already routes through_output_retand was unaffected.Note on the exit code: 2 was chosen to mirror the non-batch "No return received" path exactly (the reporter's stated expectation). If maintainers prefer a different code here I'm happy to adjust.
Merge requirements satisfied?
changelog/57357.fixed.mdtests/pytests/unit/cli/test_salt.py: no-match exits 2 (pins the bug), matched minions use the highest job retcode, matched-success exits 0Commits signed with GPG?
No