Skip to content

Address dropped merge forward commits - #70572

Merged
dwoz merged 57 commits into
saltstack:3008.xfrom
dwoz:dwoz/fix/70542-restore-dropped-prs
Oct 27, 2026
Merged

dwoz merged 57 commits into
saltstack:3008.xfrom
dwoz:dwoz/fix/70542-restore-dropped-prs

Conversation

@dwoz

@dwoz dwoz commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

#70543

twangboy and others added 30 commits October 25, 2026 23:31
…mq abort

The Windows integration tests and packaged MSI/NSIS install/upgrade
tests fail whenever a salt-call/salt CLI subprocess crashes with:

    ProcessResult(returncode=1073741845, stderr='Invalid argument
    (C:\projects\libzmq\src\zmq.cpp:988)\n', ...)

1073741845 = 0x40000015, Windows' STATUS_FATAL_APP_EXIT -- libzmq's
internal errno_assert aborting the process natively when a socket is
used/torn down unsafely.

The three earlier commits on this branch (7ab5c7c, 46f393d,
161b714) fixed this same abort for ZeroMQSocketMonitor, used by
PublishClient/RequestServer/PublishServer -- but salt-call only ever
touches RequestClient (a plain REQ socket), which had no such
protection: close() closed the socket and terminated the context
immediately, with zero coordination with the _send_recv coroutine
(spawned via io_loop.spawn_callback, no task reference kept) that
could still be mid poll()/recv() on that exact socket.

This is the same defect already fixed and proven on 3008.x for
RequestClient -- there it was diagnosed as a socketpair/fd leak on
Linux (saltstack#69991) rather than a Windows abort, but the root cause (close()
racing _send_recv's live socket reference) is identical. Port that
established graceful-drain pattern:

- _send_recv now captures its own _send_recv_exit_future up front and
  resolves it in a finally, on every exit path, and treats a
  (None, None) queue item as a shutdown sentinel.
- close() pushes that sentinel instead of closing the socket outright,
  then branches on whether it's running on the same thread as the
  io_loop (same-thread: let _send_recv drain on its own next
  iteration, tear down synchronously so socket/context close
  deterministically) or a different one (cross-thread: block on the
  drain finishing, bounded by a timeout, before tearing down) -- the
  same-thread/cross-thread split matters: an earlier version of this
  same port on 3008.x hung CI until it was added.
- _send_recv's own error-driven reconnect no longer calls
  self.close(); await self.connect() -- that pushed the shutdown
  sentinel onto the shared queue and then reconnected before anything
  consumed it, so the brand new _send_recv task immediately dequeued
  the stale sentinel and exited without ever handling a request. A new
  _reconnect() closes the socket and reconnects directly, bypassing
  close()'s sentinel/drain machinery entirely.
- _init_socket() now retains the spawned task (via
  salt.utils.asynchronous.aioloop(...).create_task(...), mirroring
  ZeroMQSocketMonitor.start_io_loop) instead of a bare spawn_callback,
  and normalizes the loop it hands to zmq.asyncio -- per aioloop()'s
  own docstring, handing zmq.asyncio a tornado IOLoop wrapper instead
  of the underlying asyncio loop is a documented cause of this exact
  Windows libzmq abort.
- Also fixes an adjacent bug in _init_socket(): on reconnect it created
  a throwaway zmq.asyncio.Context() before closing the old socket, then
  created a second context right after, leaking the first and never
  terminating the old socket's original context.

tests/pytests/functional/transport/zeromq/test_request_client.py's
test_request_client_send_recv_socket_closed is updated to match: close()
now drains _send_recv via the sentinel instead of yanking the socket out
from under it, so the coroutine logs the graceful shutdown trace instead
of a "socket closed" ZMQError.

Adds unit regression coverage in
tests/pytests/unit/transport/test_zeromq.py for close() before connect(),
idempotent close(), and close() blocking on the drain when called from a
different thread than the one running the io_loop.
``ZeroMQSocketMonitor.consume`` was scheduled via
``io_loop.spawn_callback`` (or ``asyncio.ensure_future`` with no strong
ref), leaving the resulting Task garbage-collectible while pending.
``stop()`` also cleared ``self._monitor_socket`` *before* signalling the
coroutine, so an in-flight ``poll()`` / ``recv_multipart()`` would race
the destructor.  On Linux and macOS this only produced an
``AttributeError: 'NoneType' object has no attribute 'recv_multipart'``
that ``consume``'s broad ``except`` swallowed.  On Windows the same race
tripped libzmq's ``errno_assert(rc >= 0)`` at ``zmq.cpp:988`` with
EINVAL, aborting the whole process with
``STATUS_FATAL_APP_EXIT`` (0x40000015 / 1073741845) -- what CI observed
as every ``salt-call saltutil.sync_all`` subprocess dying during the
``salt_minion`` autouse fixture.

Store the consume task as ``self._monitor_task`` (strong ref), snapshot
the socket inside ``consume`` before each ``await``, and cancel the
task + clear ``_running`` *before* closing the monitor socket in
``stop()``.
…ns repack

Two more semantic-audit follow-ups; both dropped by the ``Revert PR saltstack#69622``
cleanup and covered by tests already carried across the merge-forward.

* ``salt/channel/server.py``: include the offending minion id in the
  ``minimum_auth_version`` rejection warning (c18215a, saltstack#68671). The
  functional regression test explicitly asserts that the minion id lands
  in caplog. Fixes
  ``test_req_server_channel::test_handle_message_rejects_old_protocol_version``.

* ``salt/minion.py``: guard the new ``self.functions.pack["__pillar__"]``
  re-pack in ``pillar_refresh`` on ``getattr(self, "functions", None) is
  not None``. The 3006.x-origin functional pillar-refresh test suite
  (``test_proxy_pillar_refresh.py`` + ``test_proxy_exec_pillar_refresh.py``)
  builds bare ``Minion.__new__(...)`` / ``ProxyMinion.__new__(...)``
  instances to exercise the refresh path in isolation -- ``functions``
  is still ``None`` (the initialized-in-``gen_modules()`` state), so an
  unconditional ``self.functions.pack[...]`` raised ``AttributeError``
  and knocked out all six pillar-refresh tests + the deltaproxy sub-proxy
  isolation test. The follow-up proxy re-pack (``self.proxy.pack``) is
  already gated on ``opts["proxy"] and getattr(self, "proxy", None)``; do
  the same here so the shape is consistent.

Also un-fix the functional pusher test (``test_event_publisher.py``);
my ``publish``-vs-``send`` attribute switch reveals a deeper 3007.x
transport-rewrite bug in ``PublishClient.recv`` (unpacker yields a
non-dict frame so ``msg[b"body"]`` raises ``TypeError: 'int' object is
not subscriptable``). Not skipping per the no-preexisting-failures rule;
the primary 69914 regression is still covered by the unit-level
``test_fire_event_closes_pusher_on_send_failure`` test.
Continuation of the semantic-audit sweep. All four were on 3006.x with
their tests, then reverted out of 3007.x by the botched-merge cleanup.

* salt/modules/napalm_network.py (66fd95a, saltstack#69795): guard the
  ``salt://`` precheck with ``isinstance(template_name, str)`` so
  ``load_template(template_source=...)`` (which passes
  ``template_name=None``) stops raising ``AttributeError: 'NoneType'
  object has no attribute 'startswith'``. Fixes
  ``test_load_template_inline_source``.

* salt/master.py + salt/client/__init__.py (a651bc0, saltstack#69649/saltstack#66457):
  in ``ClearFuncs.publish``, treat a dict from ``_prep_jid`` the same as
  ``None`` and propagate the error load unwrapped. On the client, coerce
  a bare-string payload into ``{"error": payload}`` so ``payload.pop``
  works and the error surfaces as ``PublishError`` instead of
  ``AttributeError: 'str' object has no attribute 'pop'``. Fixes
  ``test_publish_prep_jid_returns_none``,
  ``test_publish_prep_jid_returns_error_dict``, and
  ``test_local_client_pub_handles_str_payload``.

* salt/utils/event.py (9653c4d / 66034 upstream): raise a warning
  when ``SaltEvent.unpack`` hits ``SaltDeserializationError``, and skip
  ``fire_ret_load`` cleanly (with an error log) when a minion's
  ``return`` payload isn't a dict, instead of crashing with
  ``AttributeError`` on ``ret.items()``. Also enrich the outer
  exception log with the minion id. Fixes
  ``test_event_unpack_with_SaltDeserializationError``,
  ``test_fire_ret_load_list_return_skips_quietly_69730``, and
  ``test_event_fire_ret_load``.

Test-side adjustments:

* ``tests/pytests/unit/metaproxy/test_deltaproxy.py::test_subproxy_post_master_init_isolates_schedule``:
  wrap the ``subproxy_post_master_init`` call in ``IOLoop.run_sync`` --
  the function is a ``@tornado.gen.coroutine``, so calling it directly
  returned a Future (not subscriptable). Also patch
  ``salt.pillar.get_async_pillar`` (not ``get_pillar``) so the mocked
  proxy pillar actually gets used and the code doesn't reach the real
  ``opts["file_client"]`` lookup that KeyErrors.
* ``tests/pytests/unit/utils/event/test_event.py::test_fire_event_closes_pusher_on_send_failure``:
  the 3007.x sync-loop pusher primitive is ``publish``, not ``send``
  (3006.x used ``send`` via ``io_loop.spawn_callback``). Track the
  attribute that ``fire_event`` actually calls so the exception path
  runs and the reset-and-reraise contract is exercised.
Two more semantic-audit follow-ups. Both PRs (saltstack#69651 spwd-removal and
cleanup rewound, so the tests are failing on every Linux + Arm64 unit-2
shard.

* ``salt/modules/junos.py``: fall back to ``yamlloader.ordereddict`` when
  ``yamlordereddictloader`` is absent. junos-eznc >= 2.7 (what py3.11+
  now pulls in) dropped that dep in favour of yamlloader and exposes the
  same ``SafeLoader``. Without the fallback, ``HAS_JUNOS`` becomes False
  under py3.11 -- salt/modules/junos.py never defines
  ``RpcTimeoutError``/``ConnectClosedError``, and the lock/unlock/
  get_table paths raise NameError from inside their ``except`` clauses
  (34 test_junos.py failures on shard 2). Fixes
  ``test_junos::test_virtual_all_true``, all ``test_lock_error`` /
  ``test_unlock_error`` / ``test_get_table_*`` / ``test_install_config*``
  / ``test_shutdown_*`` / ``test_file_copy*`` regressions.

* ``salt/modules/linux_shadow.py``: re-apply saltstack#64264/saltstack#69651 (030e255)
  which the botched-merge revert undid. Drop the ``import spwd`` (removed
  in Python 3.13), add a local ``struct_spwd`` namedtuple + reroute the
  ``info``/``list_users``/_getsp{nam,all}`` paths to the pre-existing
  ``_getspnam``/``_getspall`` /etc/shadow readers. Fixes
  ``test_linux_shadow::test_info[md5|sha256|sha512]`` and
  ``test_module_import_does_not_reference_spwd``.

* ``tests/pytests/unit/proxy/test_junos.py::test_init``: soften the
  ``ncclient.manager.connect`` assertion so it doesn't break when
  ncclient adds passthrough kwargs (``bind_addr`` in the current
  version). We only care about the salt-driven kwargs; everything else
  is ncclient-version-dependent noise.
…ack#69139)

The LazyLoader put Salt's own source directories on the global sys.path
while a module body executed (__populate_sys_path, and the fpath_dirname
append in _load_module). Any bare import issued while that module ran could
then resolve to a same-named single-file Salt module and get cached in
sys.modules for the life of the process.

That is what broke napalm on modern Salt. Loading salt/utils/napalm.py runs
its top-level `import napalm`, which reaches ncclient.transport, which does a
bare `import ssh` to detect the optional ssh-python/libssh package. With
salt/utils on sys.path that bound to salt/utils/ssh.py (a plain module, not
the ssh-python package), so ncclient's `from ssh.channel import Channel`
raised "'ssh' is not a package", `import napalm` failed, HAS_NAPALM was False,
and the napalm proxy/execution modules never passed their __virtual__ gate.
This is the root cause behind the "Proxymodule napalm is missing an init()"
reports in saltstack#69139 (which saltstack#69330 only improved the error message for).

Salt-internal modules are imported via their fully-qualified salt.* names, so
they never needed sys.path; only external/custom module dirs do, so a custom
module's bare sibling imports keep resolving. Skip appending any directory
under SALT_BASE_PATH in both __populate_sys_path and the fpath_dirname append.

As a side effect, a module whose optional same-named dependency is not
installed no longer "loads" by importing itself.
…ack#69139)

The unit tests monkeypatch SALT_BASE_PATH and use a synthetic shadow file.
This drives the real minion_mods + utils loaders against the real
SALT_BASE_PATH and asserts, from inside a module body executed mid-load, that
no Salt-internal directory is ever placed on sys.path -- the name-independent
guarantee that protects every salt/utils and salt/modules collision (dns,
napalm, git, pip, consul, ...), not just ssh. The concrete salt/utils/ssh.py
shadow is also asserted when a real top-level ssh is absent.
The NSIS stress tests still hit intermittent installer Abort (exit
code 2) after the previous retry fix, on both 3006.x and 3007.x.
Timing recovered from the CI logs shows the SCM held the
salt-minion service key for 25s+ before the uninstall side's own
wait_svc_deleted loop and the test harness's post-uninstall wait
both gave up, leaving only ~10s of retry budget on the install side
before it aborted -- not enough headroom for the observed delay.
Wait for the salt-minion service registry key to disappear before
even attempting "ssm install" (CreateService), instead of only
reacting after CreateService fails. This is a no-op on a normal
install, since the key was never present. Also widen the existing
retry budgets: the install-side CreateService retry from 5x2s to
10x2s, and the uninstall-side wait_svc_deleted from 10s to 15s.

Add diagnostics so future occurrences don't require a fresh
repro: print the tail of the relevant %TEMP%\SaltInstaller\*.log
directly into the pytest failure output on any non-zero exit or
timeout, and upload the full log directory as a CI artifact from
both the Logic Tests and Stress Tests jobs.
Adds opt-in minion_memory_headroom (accepts "5%" / "5G" / int bytes) and
minion_memory_max (bytes / size string) config options with silent
cgroup v1 / v2 detection. When either opt is set, the reference "total
memory available" is resolved from config > cgroup-v2 > cgroup-v1 >
psutil.virtual_memory().total, and used bytes come from the matching
tier. When neither opt is set the check preserves the legacy
psutil.virtual_memory().percent > 95 behavior byte-for-byte, so no
minion changes behavior on upgrade.

Refs saltstack#69884
Complements the unit-level matrix in
tests/pytests/unit/test_minion_memory_headroom.py by booting a real
minion daemon with each opt combination and driving the runtime check
via a subprocess that loads the minion's on-disk config through
salt.config.minion_config and calls Minion._has_memory_headroom.

Four scenarios:
  * config round-trip via salt-call --local config.get
  * default preserved (no opts -> legacy True on any healthy host)
  * config override -> deterministic True (huge max, tiny reserve)
  * config override -> deterministic False (tiny max, full reserve)

All scenarios use deterministic config values so no system-memory
pressure is required.

Refs saltstack#69884
The unit tests on `_pip_environment` prove the helper injects
`PIP_DISABLE_PIP_VERSION_CHECK=1` (and respects an operator override)
but would still pass if a future refactor stopped routing `salt_pip`
through `_pip_environment`. Add two end-to-end tests that drive
`salt.scripts.salt_pip` with a stubbed `subprocess.run` and assert on
the `env` dict actually handed to the child `python -m pip` process.

Refs saltstack#70024
`salt-pip` shells out to `python -m pip` against a packager-pinned onedir
pip; pip's periodic "A new release of pip is available" HTTPS check is
pure noise (the user can't do anything about it) and a proxy-config
gotcha (cf. saltstack#69910). `salt/modules/pip.py` already suppresses it on 6
install/list/upgrade paths; salt-pip should too.

Set `PIP_DISABLE_PIP_VERSION_CHECK=1` in `_pip_environment` via
`setdefault` so operators can opt back in by exporting
`PIP_DISABLE_PIP_VERSION_CHECK=0` before invoking salt-pip.

Fixes saltstack#70024
- get_device_opts: optional_args explicitly set to null yielded None (the get
  default only applies to a missing key), crashing the "config_lock" membership
  test; and a present optional_args dict was mutated in place, leaking the
  config_lock / keepalive defaults into the caller's opts/pillar. Use
  copy.deepcopy(device_dict.get("optional_args") or {}).

- proxy_napalm_wrap: force_reconnect did opts["proxy"].update(**kwargs)
  unconditionally, raising KeyError on a straight (non-proxy) minion which has
  no 'proxy' key. That merge is only for the always-alive proxy path; a straight
  minion picks the override up from clean_kwargs, so guard it with is_proxy().

- proxy.shutdown: a trailing comma made 'port' a 1-tuple, so a failed close()
  logged ':(830,)' / ':(None,)'. Remove it.
…stack#55332)

An always-alive NAPALM proxy runs with multiprocessing disabled, so jobs
executing at the same time are threads that share one cached device object and
its single command channel (get_device returns the same device by reference).
Two concurrent calls -- e.g. net.cli, or a grains refresh landing during a
state run -- can then interleave on that channel, mixing each other's output
and, on drivers that share a raw CLI session without their own locking,
corrupting the connection.

Give each device a reentrant lock, created in get_device(), and hold it in
salt.utils.napalm.call() for the duration of the call. A reentrant lock is
required because call() re-enters itself (close/open/re-exec) on a reconnect;
a plain Lock would deadlock. Devices built without a LOCK (hand-constructed in
tests, or inherited via inherit_napalm_device) run unserialized, unchanged.

The lock is per-device, not global, so a deltaproxy hosting many sub-proxies
in one process does not needlessly serialize calls across unrelated devices.
napalm_probes.set_probes/delete_probes/schedule_probes now resolve the driver's
template and no longer return result=True for the bare-name mock, so the legacy
unittest-style tests (which asserted the pre-fix behaviour) fail. They are
superseded by tests/pytests/unit/modules/napalm/test_probes.py added here, which
covers config/results plus the routing and no-template paths.
napalm_ntp (set_peers/set_servers/delete_peers/delete_servers), napalm_snmp
(update_config/remove_config) and napalm_probes (set_probes/delete_probes/
schedule_probes) all call net.load_template with a bare template name (e.g.
"set_ntp_peers"). net.load_template used to route bare names into NAPALM's own
renderer, but that path was removed in the Sodium release (saltstack#57370) -- whose own
deprecation warning explicitly told netntp/netsnmp/netusers users to ignore it.
The bare name now falls through to the fileserver as "Local file source
set_ntp_peers does not exist", so every one of these functions fails.

Lift the resolver introduced for users in saltstack#62170 into a shared
salt.utils.napalm.template_path (walks the driver class MRO + inspect.getfile,
catching TypeError/OSError, returns None when the driver ships no such template)
plus salt.utils.napalm.template_not_available (standard failure payload). The
three modules resolve the driver's NAPALM-shipped template to an absolute path
and render it through the Salt pipeline, or return the clear failure message.
template_not_available also closes the per-call connection a non-always-alive
proxy/minion opened, since it short-circuits net.load_template (which would
otherwise close it).

napalm_users is intentionally left to saltstack#62170; a follow-up dedups its local
resolver onto the shared one.

Validated on a live Juniper EX3400 (Junos 23.4R2): ntp.set_servers renders,
commits, is confirmed in the device config, and is removed again. (NAPALM's
junos snmp/probes templates still use py2 dict.iteritems() and need modernizing
upstream in NAPALM; the NTP templates are py3-clean.)

New tests/pytests/unit/utils/test_napalm.py covers the resolver (MRO
concrete-over-base precedence, base fall-through, OSError/TypeError skip, missing
-> None) and the close behaviour; test_ntp/test_snmp are rewritten and
test_probes added with routing tests asserting the correct template name, the
resolved path, forwarded flags, and inherit_napalm_device identity.
…altstack#65867)

junos.rpc (used by napalm.junos_rpc) builds the RPC ``op`` dict from
__pub_arg, which carries the reserved ``__kwarg__`` marker that the Salt CLI
appends to keyword arguments. On a ``get-config`` call with a ``filter`` the
marker leaked into the RPC options, and junos-eznc's ElementMaker raised
``KeyError: <class 'bool'>`` while rendering the ``True`` value as an XML
attribute, so the filter option stopped working after upgrading from 3004.

Strip dunder keys from ``op`` with salt.utils.args.clean_kwargs (already used
by junos.diff) right after it is assembled, so reserved markers are dropped
on every RPC path. Adds regression tests for the get-config and non
get-config paths.
)

napalm.junos_cli defaults dev_timeout to None and forwards it, so the Junos
_timeout_decorator / _timeout_decorator_cleankwargs wrappers hit
max(None, 0) -- which raises TypeError -- and would otherwise try to set the
junos-eznc connection timeout to None, which it rejects.

Coalesce None to 0 when computing the effective timeout, and only override the
connection timeout when a real (>0) dev_timeout/timeout is given; otherwise run
the command with the connection's default timeout. This makes junos_cli and the
other timeout-decorated calls work when no timeout is passed, while still
honouring an explicit dev_timeout/timeout.
…3056)

Concurrent state/orchestration renders shared a single class-level
HighState.stack list. When the reactor renders orchestrations in parallel
worker threads (it runs them inline, without forking), one render's
push_active was visible to another, so HighState.get_active could return the
wrong HighState in the middle of a render. This surfaced as an IndexError
popping an empty pydsl render stack, or KeyError: '__env__' from a spuriously
detected conflicting ID.

Store the stack in a contextvars.ContextVar instead, mirroring salt.loader's
loader_ctxvar, so each execution context (and therefore each reactor worker
thread) gets its own stack. The pydsl top-file matches, previously cached in
a module-level SLS_MATCHES global with the same sharing problem, are now
cached per HighState instance. SSHHighState.push_active was a redundant
override reaching for the removed class attribute, so it now inherits the
context-backed base method. The conflicting-ID error formatter also uses
.get() so a genuine conflict reports cleanly instead of raising KeyError.
…sh_active

The saltstack#63056 refactor put the active-HighState stack accessors
(push_active/pop_active/get_active/clear_active) on HighState. But SSHHighState
subclasses BaseHighState, not HighState, and the salt-ssh state wrapper calls
st_.push_active() on every run -- so every salt-ssh state execution raised
"'SSHHighState' object has no attribute 'push_active'". Move the accessors to
BaseHighState (their shared ancestor) so both HighState and SSHHighState resolve
them and share the one context-isolated stack, restoring the original
shared-stack semantics without an SSH-specific override.

Add a regression test that exercises SSHHighState directly -- the original test
only covered HighState, which is why the break reached CI.
…xtensions bundle

The previous commit bundled typing_extensions into the salt-ssh thin, but the
thin ships the build host's (modern) typing_extensions, whose py3.8+ syntax is a
SyntaxError on a Python 3.6 target -- and it shadows the target's own compatible
typing_extensions, so importlib_metadata (imported at salt-call startup via
salt._compat) crashed before reaching any of this PR's code. That broke salt-ssh
on every py3.6 target (Rocky Linux 8, Amazon Linux 2). Reverted.

Instead, guard "import contextvars" in salt/state.py. On targets where it can
only be resolved through the thin's backport -- which drags in
immutables/typing_extensions that may be missing (a py3.9 Debian target) or
incompatible (py3.6) -- catch ImportError/SyntaxError and fall back to a shared
class-level active-HighState stack. salt-ssh runs one execution per target, so
the per-context isolation (saltstack#63056) is not needed there; on py3.7+ minions and
the onedir master/minion, stdlib contextvars is used and the isolation is
unchanged.

Validated on live Python 3.6.8 (AlmaLinux 8): a modern typing_extensions is a
SyntaxError on py3.6, and the guarded import catches both that and a missing
typing_extensions, engaging the fallback without crashing.

Adds a test for the fallback path.
…ck#54694)

The "rest of the grains" pass in salt.loader.grains() evaluated every non-core
grain in loader iteration order with last-writer-wins. Built-in ("int") grain
modules are inserted after custom ("ext", extension_modules/_grains) modules,
so they ran last and won -- inverting the documented precedence, under which a
custom grain should override a built-in grain of the same name (e.g. a custom
"interfaces" grain could not override the built-in napalm one).

Partition the non-core grains by origin using each function's namespaced
__module__ (<base>.int.grains.<name> vs <base>.ext.grains.<name>, the same
signal the loader uses at import) and evaluate the built-in group before the
custom group. Relative order within each group is preserved, so int-vs-int and
ext-vs-ext behaviour is unchanged; only int-vs-ext collisions flip to favour
the custom grain. core.* grains still run first and remain overridable.
Since 3006.26 (b45b721) the loader recorded a failed __virtual__() under
the module's __virtualname__ in missing_modules.  When two files share a
virtualname (e.g. deb_postgres.py and postgres.py both use "postgres")
and the failing one was processed first due to non-deterministic
directory iteration, the virtualname was marked missing and the real
module was skipped on subsequent lookups, breaking postgres_user/state
runs on RHEL/Rocky.

Stop reassigning module_name to virtualname on failure in
_process_virtual, so missing_modules is only keyed by the actual file
basename.  Track per-virtualname failure reasons in a new
missing_virtualnames mapping consulted by missing_fun_string(), so
collision error surfacing (issue saltstack#68625) is preserved without the
poisoning race.

Fixes saltstack#69806
Minion.pillar_refresh compiles a fresh pillar and rebinds
self.opts["pillar"] to a new dict. A proxy minion packs the pillar into
its proxy module loader once, at init, by reference
(self.proxy.pack["__pillar__"] = self.opts["pillar"]). The rebind orphans
the dict that pack still aliases, so already-loaded proxy modules keep
serving the pillar they were first packed with until the proxy restarts.

Re-pack the loader with the freshly compiled pillar after the rebind,
guarded so a regular (non-proxy) minion is unaffected. This mirrors the
existing deltaproxy __grains__ re-pack and avoids reload_modules(), so a
module's connection state and __context__ are preserved. Deltaproxy is
covered by the same change: handle_event dispatches each sub-proxy's
pillar_refresh to that sub-proxy instance, so the re-pack runs per
sub-proxy against its own loader and opts.

Out of scope: __opts__, __opts__["pillar"] and values a module copied out
of pillar during init() are load-time snapshots and stay stale under any
non-reload fix.

Fixes saltstack#58197
Minion.pillar_refresh calls module_refresh() at the top, rebuilding the
execution-module loaders (functions/returners/executors/utils) from
self.opts, and only afterwards compiles the new pillar and rebinds
self.opts["pillar"]. Each exec loader snapshots opts["pillar"] by value
when it is built, so those freshly rebuilt loaders capture the OLD pillar.

A regular minion masks this: every job rebuilds the loaders through
gen_modules() before running. A proxy minion's metaproxy job path never
does, so an exec module keeps serving the previous refresh's __pillar__
until the next refresh_pillar -- the "run the same command twice, get two
answers" symptom.

Re-run module_refresh() after the rebind so the exec loaders are rebuilt
against the freshly compiled pillar. It sits next to the saltstack#58197 proxy
re-pack in the success branch and is gated on opts["proxy"], so a regular
minion pays no extra loader rebuild and a failed compile triggers none.

Fixes saltstack#59393
…ted example

The saltstack#58407 fix makes execution modules called during pillar rendering
resolve against the target minion, so the documented match.filter_by
example (which omits the minion_id argument) now correctly matches the
minion and gets the db role. The parametrized expectation still asserted
the pre-fix web* roles, which contradicted the fix and failed in CI.
Pillar compilation loads execution modules (for salt[...] calls in pillar
templates) with the incoming opts when file_client is "local". On the
master that branch is always taken, and the incoming opts carry the
master's id, so salt["match.compound"] and friends matched against the
master rather than the minion the pillar was being compiled for (saltstack#58407).
Load them with self.opts, which __gen_opts stamps with the target
minion_id, matching the non-local branch. Masterless is unaffected
(opts["id"] already equals the minion_id there).

Fixes saltstack#58407
salt.utils.data.filter_by ran every lookup_dict key through
fnmatch.fnmatchcase, so a literal key containing glob metacharacters (the
"[" and "]" in GPU/PCI model strings such as "GP104GL [Quadro P4000]")
was parsed as a character class and never matched its own value, falling
through to the default (saltstack#60976). Try an exact string comparison before the
fnmatch fallback. The change is additive: literal keys now match and
existing glob patterns are unaffected. This also covers grains.filter_by,
pillar.filter_by, and match.filter_by, which all delegate here.

Fixes saltstack#60976
The file.comment, file.append and file.prepend states read the target
file as bytes and decode it with the system encoding purely to build a
diff. A strict decode raised UnicodeDecodeError and aborted the state
when the file contained bytes invalid in that encoding. Decode with
errors="replace" since the result is only used for the diff.

Fixes saltstack#50903
…c_pillar.aclose awaitable; pusher.publish not send
@dwoz
dwoz merged commit a178a16 into saltstack:3008.x Oct 27, 2026
1333 of 1337 checks passed
dwoz pushed a commit that referenced this pull request Oct 28, 2026
* Silence spurious ERROR log from zypperpkg search on exit code 104 (#69758)

zypper returns exit code 104 when a search matches nothing. The
search-style calls in zypperpkg (search, _get_visible_patterns,
_get_patches, and Wildcard._get_available_versions) run through
cmd.run_all, whose default success_retcodes is [0], so the 104 was
logged as a command failure even though the search itself completed
normally and correctly reported that nothing was found.

Add an ignore_not_found option to the _Zypper wrapper that whitelists
104 via success_retcodes for those search calls, so the exit code is
treated as success and no ERROR is emitted. The found case (0) and all
genuine error codes are left untouched.

Fixes #58551

Restores #69758 on 3008.x. It was dropped by the 3007.x merge-forward
#70132 and isn't in the #70572 restore (#70542). The 3008.3 release
notes already have the changelog entry, so there is no new fragment.

(cherry picked from commit a9aa0bd)

* Keep test_search_not_found_58551 off the host's rpm lock

The mocked cmd.run_all returns 104 as-is, where the real one remaps it
to 0, so _check_result treats it as an error and _is_rpm_lock opens
/var/lib/rpm/.rpm.lock. Run as a normal user on an RPM-based host, the
test fails with PermissionError. Patch _is_rpm_lock like the other
non-zero retcode tests in this file.
@dwoz
dwoz deleted the dwoz/fix/70542-restore-dropped-prs branch November 13, 2026 08:29

This branch was previously deployed

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

7 participants