Fix pgjsonb returner referencing salt.utils.jid without importing it#69043
Open
co-cy wants to merge 1 commit into
Open
Fix pgjsonb returner referencing salt.utils.jid without importing it#69043co-cy wants to merge 1 commit into
co-cy wants to merge 1 commit into
Conversation
prep_jid() and get_jids() call salt.utils.jid.gen_jid() and
salt.utils.jid.format_jid_instance() respectively, but the module
removed `import salt.utils.jid` in 3006.x. Both calls work today only
because salt.utils.args (transitively pulled in via salt.utils.data)
imports salt.utils.jid as a side effect. Any refactor of that import
chain silently breaks pgjsonb with:
AttributeError: module 'salt.utils' has no attribute 'jid'
prep_jid() in particular is called from master.py:_prep_jid() on every
job publish, where the caller only handles KeyError/TypeError, so an
AttributeError there would prevent the master from publishing jobs.
Restore the explicit `import salt.utils.jid` and add behavioural unit
tests for prep_jid() and get_jids() (none existed before): jid format,
passed_jid pass-through, and end-to-end formatting of jids-table rows
through the real salt.utils.jid.format_jid_instance().
Refs: saltstack#69042
1b8f01a to
185b6c6
Compare
Contributor
|
@co-cy conflicts need to be addressed please. |
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.jidinsalt/returners/pgjsonb.py. The module usessalt.utils.jid.gen_jid()in
prep_jid()andsalt.utils.jid.format_jid_instance()inget_jids(), but does not import the submodule. Today this worksonly because
salt.utils.args(transitively pulled in viasalt.utils.data, which the module does import) loadssalt.utils.jidas a side effect.Adds behavioural unit tests for
prep_jid()andget_jids()(noneexisted before): the
passed_jidpass-through, the default jidformat, and end-to-end formatting of
jids-table rows through thereal
salt.utils.jid.format_jid_instance().What issues does this PR fix or reference?
Fixes #69042
Previous Behavior
prep_jid()andget_jids()work only whensalt.utils.jidhasbeen loaded by some other code path before pgjsonb is exercised. In
a process where it has not been (or where a future refactor of
salt.utils.argsremoves the side effect), both raise:master.py:_prep_jid()only handlesKeyError, TypeError, so anAttributeErrorthere propagates up and prevents job publish.New Behavior
pgjsonbimportssalt.utils.jidexplicitly. The functions workregardless of import order in the surrounding process.
Merge requirements satisfied?
changelog/69042.fixed.mdtests/pytests/unit/returners/test_pgjsonb.pyCommits signed with GPG?
No.