Give deltaproxy sub-proxies a token for the master (#70071) - #70228
Open
ggiesen wants to merge 1 commit into
Open
Give deltaproxy sub-proxies a token for the master (#70071)#70228ggiesen wants to merge 1 commit into
ggiesen wants to merge 1 commit into
Conversation
A sub-proxy is constructed directly rather than going through connect_master, which is where an ordinary minion picks up self.tok, so the attribute was simply missing and every read of it raised AttributeError. In practice that is _register_resources_with_master, reached from pillar_refresh, so each saltutil.refresh_pillar and saltutil.refresh_grains failed part way through: the sub-proxy's resources were never registered with the master, and because an empty resource dict is sent deliberately to clear stale entries, stale entries were never cleared either. The pillar refresh itself completed first, so the breakage was easy to miss. post_master_init already hands each sub-proxy a req_channel, so derive the token from that channel's auth the way connect_master does. Both the parallel and serial startup branches were assigning the channel with identical code; fold that into one helper so they cannot drift. Also build the _register_resources_with_master load inside the try that already guards the send. It is best-effort, so a problem assembling the request should be reported like a failure to send it rather than escaping into pillar_refresh and aborting the rest.
twangboy
approved these changes
Sep 2, 2026
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?
Gives deltaproxy sub-proxies the token they need to talk to the master.
Credit where it is due: @waterWang diagnosed this correctly in #70073 and identified the right cause. That PR has had changes requested since 18 August with no response, and the fix it proposes sets the attribute to
Nonerather than to a token. This takes the work forward with a real token, a test, a changelog, and the 3008.x branch.What issues does this PR fix?
Fixes #70071
Root cause
A sub-proxy is constructed directly rather than going through
connect_master, which is where an ordinary minion picks upself.tok. The attribute was therefore simply missing, and every read of it raisedAttributeError.The path it is actually reached by is:
So every
saltutil.refresh_pillarandsaltutil.refresh_grainsfailed part way through. The sub-proxy's resources were never registered with the master, and since an empty resource dict is sent deliberately to clear stale entries, stale entries were never cleared either. Everything earlier inpillar_refreshcompletes first, which is why the pillar refresh still appears to work and the breakage is easy to miss.Worth recording what is not broken, since the issue is broader than the symptom: pillar refresh itself,
event.send,mine.update,status.masterand-Ipillar targeting all behave correctly without this fix. In testing, onlysaltutil.refresh_pillarandsaltutil.refresh_grainstriggered it, once per sub-proxy.The approach
post_master_initalready hands each sub-proxy areq_channel, andAsyncReqChannel.factorybuilds itsautheagerly, so the token can be derived there the same wayconnect_masterdoes it:That gives the sub-proxy a real token rather than a placeholder. Setting it to
Nonealso stops theAttributeError, becauseAsyncReqChannel._package_loadoverwritesload["tok"]unconditionally whencrypt == "aes"-- I confirmed that -- but it only holds for that one path.self.tokis also read by_fire_master_prepareand_mine_send, and the overwrite does not happen on aclearchannel, so aNonewould silently go out on the wire instead of raising.Both the parallel and serial startup branches were assigning the channel with identical code, so this folds that into one helper and they cannot drift apart.
Previous Behavior
Every
saltutil.refresh_pillaron a deltaproxy logged oneAttributeError: 'ProxyMinion' object has no attribute 'tok'per sub-proxy, and no sub-proxy's resources ever reached the master.New Behavior
No errors, and resource registration completes.
Merge requirements satisfied?
Tests written?
Yes, two in
tests/pytests/unit/metaproxy/test_deltaproxy.py: the helper builds the channel as before and derives the token from its auth, and the inverse -- a channel with noauthmust leave the sub-proxy usable rather than raising while wiring it in. Both fail against unmodified 3008.x.Verified against a live deltaproxy on 3008.2 with three sub-proxies.
saltutil.refresh_pillarbefore the change produced 3AttributeErrors, one per sub-proxy; after it produces none, with no "Unable to register resources" warnings and no errors of any kind in the log.One unrelated tidy-up in the same function
_register_resources_with_masterbuilt its load outside thetrythat already exists to tolerate registration failures, which is why a missing attribute escaped intopillar_refreshand aborted the rest of it instead of being reported like any other registration problem. Moved inside. Happy to drop this if you would rather keep the PR to one thing.Commits signed with GPG?
No