Skip to content

Fix AsyncAuth AttributeError on _creds race with creds_map (#67947) - #69666

Merged
dwoz merged 1 commit into
saltstack:3006.xfrom
dwoz:fix/issue-67947
Jul 9, 2026
Merged

dwoz merged 1 commit into
saltstack:3006.xfrom
dwoz:fix/issue-67947

Conversation

@dwoz

@dwoz dwoz commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Initializes AsyncAuth._creds in __singleton_init__ (matching the
sibling SAuth.__init__) and treats self._creds is None as the
first-authentication case in _authenticate, closing a race that could
raise AttributeError: 'AsyncAuth' object has no attribute '_creds' and
silently sever a minion's master connection.

What issues does this PR fix or reference?

Fixes #67947

Previous Behavior

When AsyncAuth.__singleton_init__ ran with the auth key absent from the
class-wide creds_map, it fell through to self.authenticate() and left
self._creds unset. If a sibling AsyncAuth for the same key (same
pki_dir + id + master_uri + key-mtime tuple) completed its own
sign_in between our construction and our _authenticate reaching the
if key not in AsyncAuth.creds_map: check, the coroutine took the else
branch and dereferenced self._creds["aes"]:

File "salt/crypt.py", line 712, in _authenticate
    elif self._creds["aes"] != creds["aes"]:
AttributeError: 'AsyncAuth' object has no attribute '_creds'

The exception aborted the coroutine mid-flight, _authenticate_future
never resolved, and the minion's channel to the master silently died.
Running jobs kept publishing results that went nowhere until the minion
was restarted. Reproduced by the reporter on Windows 3006.8 multi-master
failover minions.

New Behavior

self._creds = None is set at the top of __singleton_init__ so
_authenticate can safely inspect it, and the else-branch guard becomes
if key not in AsyncAuth.creds_map or self._creds is None: — a raced
creds_map insert during our sign_in is now handled as a normal
first-authentication rather than crashing.

Merge requirements satisfied?

  • Docs (no documented behavior change)
  • Changelog (changelog/67947.fixed.md)
  • Tests written/updated (tests/pytests/unit/test_crypt.py::test_authenticate_missing_creds_attribute_67947)

Commits signed with GPG?

No (matching the rest of 3006.x history).

@dwoz
dwoz requested a review from a team as a code owner July 3, 2026 11:48
@dwoz dwoz added this to the Sulphur v3006.28 milestone Jul 3, 2026
@dwoz dwoz added the test:full Run the full test suite label Jul 3, 2026
AsyncAuth.__singleton_init__ only assigned self._creds when the key was
already in the class-wide creds_map. When it was not, __init__ fell
through to self.authenticate() and left _creds unset. If a sibling
AsyncAuth for the same key (same pki_dir + id + master_uri +
key-mtime tuple) completed its sign_in between our construction and
our _authenticate reaching the `if key not in AsyncAuth.creds_map:`
check, the coroutine took the else branch and dereferenced
self._creds["aes"], raising

    AttributeError: 'AsyncAuth' object has no attribute '_creds'

That crash aborted the authenticate coroutine mid-flight, so
_authenticate_future never resolved, the minion's connection to the
master silently died, and running jobs continued to publish results
into the void until manual restart. It reproduced most often on
multi-master failover minions where several AsyncAuth instances race
for the same key.

Initialize self._creds = None in __singleton_init__ (matching the
sibling SAuth.__init__) and treat `self._creds is None` as the
first-authentication case in _authenticate, so the else branch is only
entered when we have prior creds to compare against.

Fixes saltstack#67947

This branch was previously deployed

1 inactive deployment
ci — 0eb9617e Deployed Jul 3, 2026 by dwoz via Build Onedir Packages / macOS (arm64) #25147
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants