Repository navigation
Propagate cluster AES key to peers on rotation - #70573
Merged
dwoz merged 2 commits intoOct 28, 2026
Merged
Conversation
Fixes saltstack#70543. Under cluster_isolated_filesystem: True, the cluster AES key rotation only touched the rotating master's local cluster_pki_dir/.aes. Peers received the rotate_cluster_aes_key event and responded by re-reading their own untouched .aes, keeping the old key — the cluster diverged until a peer re-joined. The rotating master now encrypts the freshly-generated cluster_aes once per peer (loaded from cluster_pki_dir/peers/<peer_id>.pub) and ships the {peer_id: ciphertext} map in the event payload, mirroring the join-reply pattern. EventMonitor.handle_event decrypts its own entry with master.pem and writes the new key to local .aes before the reload path reads it back. Also removes the stale .dfn dropfile after a publish_session rotation in Maintenance.handle_key_rotate; previously the next maintenance tick's first branch saw the leftover dropfile and triggered a second rotation, flipping the key twice per cycle on the same master. Follow-up (not in scope here): the publish_session rotator-election mechanism still relies on the per-master .dfn file; cluster_isolated_filesystem makes it visible only locally so each master still elects itself. The reporter suggests replacing it with the Raft leader; tracked separately. Files touched: salt/master.py — rotate_cluster_secret per-peer payload, _build_rotate_peer_payload, EventMonitor._install_rotated_cluster_aes, handle_key_rotate .dfn cleanup. tests/pytests/functional/cluster/test_rotate_isolated_fs.py — regression. changelog/70543.fixed.md.
Address review caveats on PR saltstack#70573 by broadening the regression guards beyond the API-level installer test: * ``test_handle_event_rotate_tag_installs_new_key`` — pins the ``EventMonitor.handle_event`` dispatch wiring so a future refactor that stops calling ``_install_rotated_cluster_aes`` or ``rotate_cluster_secret(owner=False)`` from the dispatcher fails loudly. * ``test_handle_event_rotate_tag_requires_peer_id`` — a stray local event with no ``__peer_id`` must NOT trigger the install; guards against an attacker-forged local event rewriting ``.aes``. * ``test_multiple_independent_rotators_still_converge`` — covers the reporter's secondary observation that each master has its own private ``cachedir/.dfn`` under ``cluster_isolated_filesystem: True`` and can independently decide to rotate; the fix must still deliver convergence under this scenario. Replacing the ``.dfn``-per-master layout with a Raft-leader election is tracked separately as a follow-up.
twangboy
approved these changes
Oct 28, 2026
This branch was previously deployed
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.
Fixes #70543.
Under
cluster_isolated_filesystem: True, the rotating master encrypts the freshly-generatedcluster_aesonce per peer (loaded fromcluster_pki_dir/peers/<peer_id>.pub) and ships the{peer_id: ciphertext}map in therotate_cluster_aes_keyevent.EventMonitoron each receiver decrypts its own entry withmaster.pemand writes the new key to local.aesbefore the reload. Pattern mirrors the join-reply.Secondary fix:
Maintenance.handle_key_rotatenow removes the.dfndropfile after thepublish_sessionbranch triggers a rotation. Previously the next maintenance tick's first branch saw the leftover dropfile and rotated again — doubled rotations per cycle on the same master.Follow-up (separate issue): the
publish_sessionleader election still uses a per-master.dfnwhich with isolated filesystems means each master elects itself. The reporter suggests replacing it with the Raft leader; tracked separately.Test plan
.aesSHA-256 after rotation (agents/scratch/70543-repro/)tests/pytests/functional/cluster/test_rotate_isolated_fs.py— 5 new tests covering propagation, legacy-payload tolerance, missing-self-entry, missing peer pub, and.dfncleanuptests/pytests/{unit,functional}/cluster/697 existing tests still passtests/pytests/unit/test_master.py133 pass / 25 Windows-skipped