Skip to content

Fix RPM upgrade leaving previously-running salt-minion stopped (#69605) - #69610

Merged
dwoz merged 2 commits into
saltstack:3006.xfrom
dwoz:dwoz/fix/issue-69605-minion-stop-on-upgrade
Jul 1, 2026
Merged

dwoz merged 2 commits into
saltstack:3006.xfrom
dwoz:dwoz/fix/issue-69605-minion-stop-on-upgrade

Conversation

@dwoz

@dwoz dwoz commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes the RPM upgrade scriptlets so a salt-minion service that was
running before the upgrade is still running afterward. The %pre minion
scriptlet now records the unit's pre-upgrade active state; %posttrans minion consults that marker and calls systemctl start (not just
try-restart) so the deliberate stop in %pre no longer leaves the
service inactive.

What issues does this PR fix or reference?

Fixes #69605

Previous Behavior

The %pre minion scriptlet unconditionally stopped salt-minion.service
on upgrade so the ownership-restoration chowns in %post / %posttrans
wouldn't race a live minion. Both %post and %posttrans then only
called systemctl try-restart salt-minion.service, which by design is a
no-op for an inactive unit. Every RPM upgrade on an EL host therefore
left the previously-running minion stopped, with no automatic recovery
short of logging into each host. The regression existed since 3006.24
(when commit 3e51839232d added the systemctl stop to %pre) and is
still present on 3007.x, 3008.x, and master - the fix will ride the
merge-forward branches up.

New Behavior

%pre minion runs systemctl is-active --quiet salt-minion.service
before the stop, touching /tmp/.salt-minion-upgrade-was-active when
the unit was active. %posttrans minion checks that marker at the end
and invokes systemctl start salt-minion.service (deleting the marker
afterward) when it is present. If the marker is absent (fresh install,
or the unit was already stopped before the upgrade) the historical
try-restart fallback runs - matching the prior semantics for that
case.

Regression tests

  • tests/pytests/unit/pkg/test_rpm_minion_scriptlets.py - static spec
    audit that runs in ordinary unit-test CI (no rpmbuild, no systemd).
    Asserts %pre minion records the pre-stop active state and that
    %posttrans minion calls systemctl start when the marker is set.
    This is the test that would have caught the regression.
  • tests/pytests/pkg/upgrade/systemd/test_service_preservation.py::test_salt_minion_running_after_upgrade
    • end-to-end check for the packaging upgrade matrix. Starts the
      minion before the upgrade, runs install(upgrade=True), and asserts
      systemctl is-active salt-minion returns active afterward.

Merge requirements satisfied?

  • Docs (no documented behavior change; comment in spec explains)
  • Changelog (changelog/69605.fixed.md)
  • Tests written/updated

Commits signed with GPG?

Yes

The %pre minion scriptlet unconditionally stops salt-minion.service on
upgrade so the ownership-restoration chowns in %post / %posttrans don't
race a live minion. Both %post and %posttrans only call
``systemctl try-restart``, which is a documented no-op when the unit
is inactive. The combination silently broke RPM upgrades on every EL
host: the minion was stopped by %pre and never started again, leaving
operators with no automatic recovery short of logging into each host.

Record whether the unit was active before %pre stops it, and in
%posttrans invoke ``systemctl start`` (not just ``try-restart``) when
that marker is set. Keep the ``try-restart`` fallback for the case
where %pre observed the unit as inactive, matching the prior
fresh-install / unit-was-already-stopped semantics.

The regression existed since 3006.24, when the
ownership-preservation logic added the ``systemctl stop`` to %pre.
Add a static spec audit under tests/pytests/unit/pkg/ that runs in
ordinary unit-test CI (no rpmbuild, no systemd) plus an end-to-end
running-minion preservation check under
tests/pytests/pkg/upgrade/systemd/ for the packaging matrix.

Fixes saltstack#69605
@dwoz
dwoz requested a review from a team as a code owner June 30, 2026 22:13
@dwoz dwoz added this to the Sulphur v3006.27 milestone Jun 30, 2026
@dwoz dwoz added the test:full Run the full test suite label Jun 30, 2026
The first version called ``install_salt_systemd.install(upgrade=True)``
to drive the upgrade. That method calls ``restart_services()``
unconditionally after the package upgrade on systemd RPM hosts (see
SaltPkgInstall.install in tests/support/pkg.py), which runs
``systemctl restart salt-minion`` and would mask the regression: the
%pre / %posttrans scriptlets could leave the unit stopped and the
post-upgrade restart would paper right over it. The same masking
applies to ``test_salt_upgrade`` itself, which already includes a
hard-coded ``systemctl restart`` workaround for "services are not
always restarted after upgrade" (test_salt_upgrade.py line 180).

Rewrite the regression test to:

* Skip on non-RPM distros (the bug is RPM scriptlet-specific; Debian
  salt-minion.preinst doesn't ``systemctl stop``).
* ``systemctl start salt-minion`` directly via subprocess and poll
  ``is-active`` until the unit reports ``active``.
* Drive the upgrade by invoking ``yum upgrade -y <pkgs>`` directly
  (mirroring ``SaltPkgInstall._install_pkgs`` for the upgrade path
  but without the post-upgrade ``restart_services()`` step that
  would mask the bug).
* Between the upgrade and the final assertion, poll ``is-active``
  read-only and never issue ``start`` / ``restart``. The scriptlets
  must bring the unit back on their own.

Pre-commit clean. Walked the test logic through a standalone
reproduction inside an EL9 systemd container against both the
unfixed and the fixed scriptlets: unfixed leaves ``is-active``
returning ``inactive`` and the test fails with its written error
message; fixed leaves ``is-active`` returning ``active`` and the
test passes.

Refs saltstack#69605
@dwoz
dwoz merged commit 861641f into saltstack:3006.x Jul 1, 2026
428 checks passed
@dwoz
dwoz deleted the dwoz/fix/issue-69605-minion-stop-on-upgrade branch November 13, 2026 08:30

This branch was previously deployed

1 inactive deployment
ci — 3c173a00 Deployed Jul 1, 2026 by dwoz via Build Onedir Packages / Windows (x86) #24925
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.

1 participant