Fix loader race poisoning OS-specific virtualnames - #69963
Open
dwoz wants to merge 1 commit into
Open
Conversation
Since 3006.26 (b45b721) the loader recorded a failed __virtual__() under the module's __virtualname__ in missing_modules. When two files share a virtualname (e.g. deb_postgres.py and postgres.py both use "postgres") and the failing one was processed first due to non-deterministic directory iteration, the virtualname was marked missing and the real module was skipped on subsequent lookups, breaking postgres_user/state runs on RHEL/Rocky. Stop reassigning module_name to virtualname on failure in _process_virtual, so missing_modules is only keyed by the actual file basename. Track per-virtualname failure reasons in a new missing_virtualnames mapping consulted by missing_fun_string(), so collision error surfacing (issue saltstack#68625) is preserved without the poisoning race. Fixes saltstack#69806
twangboy
approved these changes
Aug 5, 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?
Fixes a race in
salt.loader.lazy._process_virtual(introduced by b45b721 in 3006.26) that caused OS-specific virtual modules to randomly fail to load. When a sibling module (e.g.deb_postgres.py) evaluated its__virtual__()first and returnedFalse, its__virtualname__(postgres) was written tomissing_modules, blocking the realpostgres.pymodule on subsequent lookups.The fix stops reassigning
module_nametovirtualnameon failure inside_process_virtual, somissing_modulesis keyed only by real file basenames. Per-virtualname failure reasons are tracked in a newmissing_virtualnamesmapping consulted bymissing_fun_string(), preserving the collision-surfacing behavior added for #68625.Test evidence
test_virtualname_sibling_failure_does_not_poison_real_modulefails on unpatched code and passes with the fix.test_virtualname_collision_surfaces_all_reasons(from [Bug]: x509_v2 module can't be used with salt-ssh #68625) still passes.Fixes