fix: import salt.utils.jid explicitly in pgjsonb returner (#69042)#69128
Open
SAY-5 wants to merge 1 commit into
Open
fix: import salt.utils.jid explicitly in pgjsonb returner (#69042)#69128SAY-5 wants to merge 1 commit into
SAY-5 wants to merge 1 commit into
Conversation
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?
Restores the explicit
import salt.utils.jidin thepgjsonbreturner. The module callssalt.utils.jid.gen_jid()inprep_jid()(line 461) andsalt.utils.jid.format_jid_instance()inget_jids()(line 436), but currently only importssalt.utils.dataandsalt.utils.job. Thesalt.utils.jidreference works today as a side effect ofsalt.utils.argsbeing loaded transitively viasalt.utils.data. Any refactor of that import chain silently breakspgjsonbwithAttributeError: module 'salt.utils' has no attribute 'jid'.prep_jid()is called frommaster.py:_prep_jid()on every job publish. That caller only handlesKeyError, TypeErrorso the latentAttributeErrorwould propagate and prevent the master from publishing jobs whenmaster_job_cache: pgjsonbis in use.A regression test in
tests/pytests/unit/returners/test_pgjsonb.pyasserts thatsalt.utils.jidis reachable through the module's globals so future refactors can no longer drop the explicit import.What issues does this PR fix or reference?
Fixes #69042
Previous Behavior
prep_jid/get_jidsworked only becausesalt.utils.jidwas loaded transitively. In an interpreter where it had not been loaded yet, both functions raisedAttributeError: module 'salt.utils' has no attribute 'jid'.New Behavior
The explicit
import salt.utils.jidis restored alongside the existingsalt.utils.data/salt.utils.jobimports, so both call sites resolve regardless of which other modules have been imported beforehand.Merge requirements satisfied?
changelog/69042.fixed.mdCommits signed with GPG?
No