Repository navigation
Description
Description
I have a minion on my local network connecting to a cloud-based master. That minion never shows as connected, but all my minions with public IP addresses do show as connected. That is, the local minion doesn't show as connected in SaltGUI, nor show up in the results of salt-run manage.present. However, salt functions still work because it is actually connected.
I did some digging around in the Salt source code and discovered that the problem is in the way Salt determines whether a minion is connected.
It works like this:
- Get the list of known minions.
- Run
ss -ant src <master_publish_port>to get a list of active network connections to the master's port. - Compare the list of active connections with each minion's reported IP addresses (like running
ip addresson the minion). - If one of the minion's reported IP addresses is in the list of connections, it must be connected.
- If not, then it is assumed disconnected.
The problem is that when a minion is behind NAT, it doesn't know its public IP address, and therefore is never connected according to this algorithm. A much better way to do it would be for the Salt master to keep a list of the minions that it received a connection from.
However I am not familiar with ZeroMQ so maybe this is impossible?
Setup
Please be as specific as possible and give set-up details.
- on-prem machine
- VM (Virtualbox, KVM, etc. please specify)
- VM running on a cloud service, please be explicit and add details
- container (Kubernetes, Docker, containerd, etc. please specify)
- or a combination, please be explicit
- jails if it is FreeBSD
- classic packaging
- onedir packaging
- used bootstrap to install
Steps to Reproduce the behavior
salt-run manage.present
is showing
- (all minions except fs2)
Expected behavior
salt-run manage.present
should show
- fs2
- (other minions)
Versions Report
Salt Version:
Salt: 3007.0
Python Version:
Python: 3.10.13 (main, Feb 19 2024, 03:31:20) [GCC 11.2.0]
Dependency Versions:
cffi: 1.16.0
cherrypy: unknown
dateutil: 2.8.2
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
Jinja2: 3.1.3
libgit2: Not Installed
looseversion: 1.3.0
M2Crypto: Not Installed
Mako: Not Installed
msgpack: 1.0.7
msgpack-pure: Not Installed
mysql-python: Not Installed
packaging: 23.1
pycparser: 2.21
pycrypto: Not Installed
pycryptodome: 3.19.1
pygit2: Not Installed
python-gnupg: 0.5.2
PyYAML: 6.0.1
PyZMQ: 25.1.2
relenv: 0.15.1
smmap: Not Installed
timelib: 0.3.0
Tornado: 6.3.3
ZMQ: 4.3.4
Salt Package Information:
Package Type: onedir
System Versions:
dist: debian 12.5 bookworm
locale: utf-8
machine: x86_64
release: 6.1.0-18-amd64
system: Linux
version: Debian GNU/Linux 12.5 bookworm
Additional context

Activity
welcome commentedon Apr 2, 2024
Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey.
Please be sure to review our Code of Conduct. Also, check out some of our community resources including:
There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar.
If you have additional questions, email us at [email protected]. We’re glad you’ve joined our community and look forward to doing awesome things with you!
18 remaining items
research(liveness): why presence is broken on 0MQ, and where it is not
cstrahan commentedon Oct 23, 2026
Confirming this still reproduces on 3008.3, and adding some findings from
digging into it that I think change how it should be scoped.
Setup: a master managing minions across two networks.
manage.presentreturnsonly the minions local to the master's own network; minions in the other
network are absent while
salt -C '<id>' test.pinganswerstrueinstantly.There is no fallback — every id-level presence path is the same check
manage.present/alived/joined/allowed/reapedlist_state()→CkMinions.connected_ids()presence_eventsconnected_ids()(master.py,Maintenance.handle_presence)wheel minions.connectedcon_cacheif enabled, elseconnected_ids()con_cacheCacheWorker.run()→connected_ids()So there's no "use X instead" workaround to point people at — they all inherit
the grains-IP comparison.
con_cachelooks like a workaround but isn'tThis one surprised me. The master records the correct id at authentication:
That's NAT-safe, since auth carries the id. But then:
Correct ids go in at auth and the periodic refresh sweeps them back out. So
con_cache: Truedoesn't help here, which is worth knowing before suggestingit.
Also:
detect_remote_minionsisn't applicable — it defaults off and keys onremote_minions_port, default 22, which is a different (salt-ssh-shaped)scenario.
The TCP transport already solves this correctly
This seems like the most useful thing I found. On
transport: tcp, presence istracked in the transport, keyed by authenticated minion id:
with
remove_presence_callbackon disconnect — andMaintenance.__init__deliberately skips the
connected_ids()polling when the transport istcp-only ("For a TCP only transport, the presence events will be handled in
the transport code").
So this isn't "salt can't do correct presence", it's "0MQ doesn't, and TCP
does". The asymmetry seems like the right frame for a fix.
One dead end, to save someone the time
The obvious fix — record the source address seen at auth and match on that too
— doesn't appear implementable on 0MQ. The auth handler only receives the
decoded payload (
handle_message(self, stream, payload)→self.message_handler(payload)), and the ROUTER socket sits behind azmq_deviceproxying to workers over an internal DEALER, so the peer is goneby then; a ROUTER identity frame is a ZeroMQ identity, not an address. The
master has the id and no address.
Similarly, just making
CacheWorkerstop clobbering the auth-recorded idsisn't enough on its own — nothing would ever remove an entry, so it would
trade silent under-reporting for silent over-reporting.
Possible directions
Happy to put up a PR if a maintainer has a preference on scope:
connected_ids()can see it has establishedconnections on the publish port matching no cached minion. Logging that
count would turn a confidently-wrong answer into a detectable one. No
behaviour change; smallest useful thing.
ipv4/ipv6), so a NAT'd fleet can surface its externally-visible address as agrain and have presence work. Backward compatible, but needs operator
setup.
last-seen per id from authenticated traffic on the ret port. Bigger, and
presumably wants a maintainer's view on whether that's the direction before
anyone writes it.
cstrahan commentedon Oct 28, 2026
I've opened a discussion around one way we could resolve this: #70582
The proposed solution is implemented on one of my branches (described in that discussion).
twangboy commentedon Oct 30, 2026
Does this address the issue? #70385