Skip to content

Propagate cluster AES key to peers on rotation - #70573

Merged
dwoz merged 2 commits into
saltstack:3008.xfrom
dwoz:dwoz/fix/70543-cluster-aes-rotation-isolated-fs
Oct 28, 2026
Merged

dwoz merged 2 commits into
saltstack:3008.xfrom
dwoz:dwoz/fix/70543-cluster-aes-rotation-isolated-fs

Conversation

@dwoz

@dwoz dwoz commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Fixes #70543.

Under cluster_isolated_filesystem: True, the rotating master 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 rotate_cluster_aes_key event. EventMonitor on each receiver decrypts its own entry with master.pem and writes the new key to local .aes before the reload. Pattern mirrors the join-reply.

Secondary fix: Maintenance.handle_key_rotate now removes the .dfn dropfile after the publish_session branch 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_session leader election still uses a per-master .dfn which with isolated filesystems means each master elects itself. The reporter suggests replacing it with the Raft leader; tracked separately.

Test plan

  • Repro script converges all three masters' .aes SHA-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 .dfn cleanup
  • tests/pytests/{unit,functional}/cluster/ 697 existing tests still pass
  • tests/pytests/unit/test_master.py 133 pass / 25 Windows-skipped
  • pre-commit clean

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.
@dwoz
dwoz requested a review from a team as a code owner October 26, 2026 22:38
@dwoz dwoz added this to the Argon v3008.4 milestone Oct 26, 2026
@dwoz dwoz added the test:full Run the full test suite label Oct 26, 2026
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 twangboy modified the milestones: Argon v3008.4, Argon v3008.7 Oct 28, 2026
@dwoz
dwoz merged commit 342438a into saltstack:3008.x Oct 28, 2026
1770 of 1782 checks passed
@dwoz
dwoz deleted the dwoz/fix/70543-cluster-aes-rotation-isolated-fs branch November 13, 2026 08:30

This branch was previously deployed

1 inactive deployment
ci — a0728f32 Deployed Oct 27, 2026 by dwoz via Build Onedir Packages / DEB (arm64) #27907
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.

[Bug]: Master cluster 3008.3 (isolated filesystem): rotated cluster AES key does not seem to reach the other peers

2 participants