Skip to content

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

Closed

Description

@k-hamza

What happened?

Description

We are evaluating a 3-node master cluster rhel-9 on Salt 3008.3 with cluster_isolated_filesystem: True, each master having its own local cluster_pki_dir and cachedir.

After a few days of operation, we noticed that cluster_pki/.aes had a different content on each master.

We then tried to reproduce this in a disposable test environment, and we believe we can now show it with a short, repeatable sequence.
We may well be missing something in our setup, so please take this as a report of what we observe rather than a confirmed diagnosis.

In short:
the cluster AES key appears to be correctly delivered to a peer when it joins, but when one master rotates it, the other masters seem to receive only a signal to reload their own local file, not the new key.

Transparency note: the tests and observations below were carried out by us on our own environment. The code reading and the resulting hypotheses were produced with the help of an AI assistant (Claude, via GitHub Copilot), and have not been verified beyond what is described here. They may contain inaccuracies, and we would be grateful for any correction.

Setup

  • Salt 3008.3 (onedir), 3 masters
  • Test environment: three separate Fedora instances under WSL2, each with its own filesystem
  • cluster.pem / cluster.pub identical on the three masters before the first start
  • Default key cache driver (localfs_key)
  • HAProxy in front of 4505 / 4506, mode tcp, with balance source and hash-type consistent, so that a given minion is always served by the same master. We use this affinity to work around the per-minion session key issue reported in [Bug]: Master cluster (isolated filesystem) behind a load balancer: "Master did not return a session key for pillar request" #70399. Note that the steps below do not involve any minion, so the load balancer plays no part in this reproduction.
id: 127.0.0.11
interface: 127.0.0.11
publish_port: 4505
ret_port: 4506

cluster_id: salt_master_cluster
cluster_secret: <secret>
cluster_pool_port: 4520
cluster_isolated_filesystem: True
cluster_pki_dir: /var/lib/salt/cluster_pki
cluster_peers:
  - 127.0.0.12
  - 127.0.0.13

log_level_logfile: debug
publish_session: 86400

The two other masters use the same configuration with their own addresses.

Steps to reproduce

Step A: clean join, no rotation

On the three masters:

systemctl stop salt-master
rm -f /var/cache/salt/master/.dfn
rm -f /var/cache/salt/master/.cluster_joined.*
rm -rf /var/cache/salt/master/sessions/*
rm -rf /var/cache/salt/master/cluster/consensus
rm -f /var/lib/salt/cluster_pki/.aes /var/lib/salt/cluster_pki/peers/*

Then start master1, master2 and master3 one after the other, waiting for each to join.

Result:

master1 master2 master3
Installed cluster_aes from join-reply n/a (founder) yes yes
cluster ready — opening request gate yes yes yes
sha256sum cluster_pki/.aes a3cb4b3b… a3cb4b3b… a3cb4b3b…

So far everything looks as expected: the key is delivered on join and all three masters share it.

Step B: trigger a rotation on one master only

Without restarting anything, we age the key file of master1 only, so that its maintenance loop considers it older than publish_session:

# master1 only
touch -d '-2 days' /var/lib/salt/cluster_pki/.aes

Result, a few minutes later:

Time master1 master2 master3
17:52:04 Rotating AES key
17:52:09 Rotating cluster AES key, .aes → 085f10fd… Rotating AES session key Rotating AES session key
17:53:09 .aes → 1a888cf6… Rotating AES session key Rotating AES session key
Final sha256sum 1a888cf6… a3cb4b3b… (unchanged) a3cb4b3b… (unchanged)
Final mtime of .aes 17:53:09 unchanged since join unchanged since join

master2 and master3 clearly receive and process the rotation event, but their .aes file is not modified, and the cluster ends up with two different keys.

Expected behavior

As we understand it, all peers should share a single cluster_aes value at any time. After a rotation, the new value would be expected to reach every peer, as it does on join.

Actual behavior

Only the master that performs the rotation gets the new key. The other masters keep the previous one, and the keys stay different until a peer goes through a new join.

A possible lead, offered tentatively

(AI-assisted code reading, see the transparency note above.)

We have only read a small part of the code, so this may be off the mark.

On the rotating master, Maintenance.handle_key_rotate calls SMaster.rotate_cluster_secret(owner=True), which removes .aes, generates a new random key and fires a rotate_cluster_aes_key event:

https://github.com/saltstack/salt/blob/v3008.3/salt/master.py#L297-L329

On the other masters, EventMonitor handles that event by calling rotate_cluster_secret(owner=False):

https://github.com/saltstack/salt/blob/v3008.3/salt/master.py#L1434-L1440

rotate_cluster_secret does not call the key loader by name. It calls cls.secrets["cluster_aes"]["reload"](remove=owner), and populate_secrets() registers read_or_generate_key under that "reload" entry:

https://github.com/saltstack/salt/blob/v3008.3/salt/master.py#L340-L352

So owner ends up as the remove argument of read_or_generate_key. If we read it correctly, with remove=True the file is deleted and a new random key is written, while with remove=False the existing local cluster_pki_dir/.aes is simply re-read:

https://github.com/saltstack/salt/blob/v3008.3/salt/master.py#L1032-L1044

With a shared cluster_pki_dir, re-reading the file would indeed pick up the new key. With an isolated filesystem, the local file has not changed, so the old key is reloaded. This seems consistent with what we observe in step B.

By contrast, the join path does carry the key itself: the join-reply contains cluster_aes encrypted to the joiner's public key, and the joiner writes it to its own .aes:

https://github.com/saltstack/salt/blob/v3008.3/salt/channel/server.py#L3453-L3477

We also noticed that the choice of which master rotates relies on a .dfn file in cachedir, with a comment acknowledging the lack of a leader:

# There is currently no concept of a leader in a master
# cluster. Let's fake it till we make it with a little
# waiting period.

https://github.com/saltstack/salt/blob/v3008.3/salt/master.py#L591-L611

With a private cachedir per master, each master would only see its own .dfn, so several masters could each decide to rotate independently. We believe this is what happened in our long-running environment, where each master rotated on its own schedule, but we have not reproduced that part in a controlled way.

Secondary observation: two rotations per cycle

This looks like a separate issue, possibly unrelated to the isolated filesystem, but it shows up in the same reproduction. Happy to open a separate ticket if that is preferred.

In step B, master1 rotated its key twice, 60 seconds apart (three successive fingerprints: a3cb… → 085f… → 1a88…). We also saw cachedir/.dfn still present right after the first rotation, and gone after the second one.

If we read handle_key_rotate correctly, the .dfn created by the publish_session branch is not removed after that rotation. On the next maintenance loop, the first branch finds the read-only .dfn, rotates again, and only then removes it:

https://github.com/saltstack/salt/blob/v3008.3/salt/master.py#L563-L619

Possible directions

Again, offered tentatively, and we would defer to maintainers on the right approach:

  • carry the new cluster_aes in the rotation event, encrypted to each peer as in the join-reply, and have receivers persist it to .aes;
  • designate a single rotating master in isolated-filesystem mode, for example the Raft leader, instead of the local .dfn mechanism;
  • remove the .dfn after a rotation triggered by publish_session.

Type of salt install

Official rpm

Major version

3008.x

What supported OS are you seeing the problem on? Can select multiple. (If bug appears on an unsupported OS, please open a GitHub Discussion instead)

rhel-9

salt --versions-report output

Salt Version:
          Salt: 3008.3

Python Version:
        Python: 3.14.7 (main, Sep 30 2026, 03:35:11) [GCC 11.2.0]

Dependency Versions:
          cffi: 2.0.0
      cherrypy: 18.10.0
  cryptography: 50.0.1
      dateutil: 2.9.0.post0
     docker-py: Not Installed
         gitdb: 4.0.12
     gitpython: Not Installed
        Jinja2: 3.1.6
       libgit2: Not Installed
  looseversion: 1.3.0
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.2.1
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     packaging: 24.0
     pycparser: 3.00
      pycrypto: Not Installed
  pycryptodome: 3.23.0
        pygit2: Not Installed
  python-gnupg: 0.5.6
        PyYAML: 6.0.3
         PyZMQ: 27.1.0
        relenv: 0.22.27
         smmap: 5.0.2
       timelib: 0.3.0
       Tornado: 6.5.10
           ZMQ: 4.3.5

Salt Package Information:
  Package Type: onedir

System Versions:
          dist: fedora 44
        locale: utf-8
       machine: x86_64
       release: 6.18.54.1-microsoft-standard-WSL2
        system: Linux
       version: Fedora Linux 44

Activity

  1. added
    bug
    on Oct 23, 2026
  2. self-assigned this
    on Oct 24, 2026
  3. added
    severity-critical
    on Oct 24, 2026
  4. added this to the Argon v3008.4 milestone on Oct 26, 2026
  5. added a commit that references this issue on Oct 28, 2026
    342438a
  6. dwoz commented on Oct 30, 2026

    @dwoz
    Contributor

    Closing as completed — implemented by merged PR #70573.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugseverity-critical

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions