Fail wheel key.accept/reject/delete when nothing is acted on (#63477)#69780
Open
ggiesen wants to merge 1 commit into
Open
Fail wheel key.accept/reject/delete when nothing is acted on (#63477)#69780ggiesen wants to merge 1 commit into
ggiesen wants to merge 1 commit into
Conversation
wheel key.accept (and reject/delete, plus their _dict variants) returned success=True even when the match named no key the command could act on: a non-existent minion, or a key present only in a state the command does not touch (e.g. rejecting an already-accepted minion without include_accepted). That is a misleading, security-relevant false positive. Set a non-zero retcode (success=False) unless the match names a key in a state the command acts on, or already in its target state (so re-asserting a key stays idempotent for saltmod.wheel orchestration). Also reset the retcode at the start of each runner/wheel low() call so a failure set on a reused client -- the master's per-MWorker ClearFuncs.wheel_ or a cached reactor client -- does not leak into later calls. Fixes saltstack#63477
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 wheel
key.accept/reject/deletefunctions (and their_dictvariants) reportsuccess=Falsewhen the match names no key the operation can act on, instead of a silent success. Also resets the runner/wheel retcode per call so a failure cannot leak across calls on a reused client.What issues does this PR fix or reference?
Fixes #63477
Previous Behavior
wheel key.accept <match>returnedsuccess=Truewith an empty result even when<match>named no key that could be accepted -- most obviously a non-existent minion (the reported case), but also a key that exists only in a state the command does not touch. Since callers, andsaltmod.wheelorchestration, treatsuccessas "the operation did what I asked", this is a misleading and security-relevant false positive. The sharpest case iskey.reject <accepted-minion>with default flags:rejectonly moves pending keys unlessinclude_acceptedis set, so it does nothing, yet reports success -- an operator believes a minion is locked out when it is still fully authorized.New Behavior
accept/reject/delete(andaccept_dict/reject_dict/delete_dict) set a non-zero retcode -- sosuccess=False-- unless the match names a key in a state the command acts on, or already in its target state. Re-asserting a key already in its target state (for example accepting an already-accepted minion) stays an idempotent success, which matters forsaltmod.wheelin orchestration.SyncClientMixin.low()never reset the retcode, and two paths reuse one long-lived client -- the master's per-MWorkerClearFuncs.wheel_and the reactor's cachedWheel-- so a failure retcode set by one call would otherwise persist and make later unrelated calls reportsuccess=False. The retcode is now reset at the start of eachlow()call, matching what the minion already does per job.Verified with a real
WheelClientagainst a temp PKI:success=False; a pending or already-accepted minion ->success=True; a rejected-only key withoutinclude_rejected->success=False.include_accepted->success=False.Merge requirements satisfied?
changelog/63477.fixed.mdtests/pytests/unit/wheel/test_key.py(per-command condition, the_dictvariants, and the reused-client leak regression; all pin-proofed against baseline)Commits signed with GPG?
No