Repository navigation
Fix RPM upgrade leaving previously-running salt-minion stopped (#69605) - #69610
Merged
dwoz merged 2 commits intoJul 1, 2026
Merged
Conversation
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
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
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes the RPM upgrade scriptlets so a
salt-minionservice that wasrunning before the upgrade is still running afterward. The
%pre minionscriptlet now records the unit's pre-upgrade active state;
%posttrans minionconsults that marker and callssystemctl start(not justtry-restart) so the deliberate stop in%preno longer leaves theservice inactive.
What issues does this PR fix or reference?
Fixes #69605
Previous Behavior
The
%pre minionscriptlet unconditionally stoppedsalt-minion.serviceon upgrade so the ownership-restoration chowns in
%post/%posttranswouldn't race a live minion. Both
%postand%posttransthen onlycalled
systemctl try-restart salt-minion.service, which by design is ano-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
3e51839232dadded thesystemctl stopto%pre) and isstill present on 3007.x, 3008.x, and
master- the fix will ride themerge-forward branches up.
New Behavior
%pre minionrunssystemctl is-active --quiet salt-minion.servicebefore the stop, touching
/tmp/.salt-minion-upgrade-was-activewhenthe unit was active.
%posttrans minionchecks that marker at the endand invokes
systemctl start salt-minion.service(deleting the markerafterward) when it is present. If the marker is absent (fresh install,
or the unit was already stopped before the upgrade) the historical
try-restartfallback runs - matching the prior semantics for thatcase.
Regression tests
tests/pytests/unit/pkg/test_rpm_minion_scriptlets.py- static specaudit that runs in ordinary unit-test CI (no rpmbuild, no systemd).
Asserts
%pre minionrecords the pre-stop active state and that%posttrans minioncallssystemctl startwhen 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_upgrademinion before the upgrade, runs
install(upgrade=True), and assertssystemctl is-active salt-minionreturnsactiveafterward.Merge requirements satisfied?
changelog/69605.fixed.md)Commits signed with GPG?
Yes