Skip to content

Auto-restart salt-minion.service on crash (#69182) - #69671

Merged
dwoz merged 2 commits into
saltstack:3008.xfrom
dwoz:fix/issue-69182
Nov 24, 2026
Merged

dwoz merged 2 commits into
saltstack:3008.xfrom
dwoz:fix/issue-69182

Conversation

@dwoz

@dwoz dwoz commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds Restart=on-failure, RestartSec=15, StartLimitBurst=3, and
StartLimitIntervalSec=300 to the shipped pkg/common/salt-minion.service
systemd unit so that a crashed minion (unhandled exception, worker OOM,
etc.) is revived by systemd instead of being left in the failed state.

What issues does this PR fix or reference?

Fixes #69182

Related: #68406 (the recent KillMode=mixed fix on the same file — this
PR extends the tests/pytests/unit/test_pkg_systemd_units.py static
audit added there).

Previous Behavior

The shipped unit had no Restart=/RestartSec=/StartLimit* directives.
When the salt-minion process crashed the unit went to failed and
stayed there until someone ran systemctl start salt-minion by hand. As
the reporter observed on 3008.0rc4 (Ubuntu 22.04) and a second contributor
confirmed on 3007.14 (Rocky 9), an unhandled exception took the minion
offline from the master's point of view until the next manual intervention.

New Behavior

Restart=on-failure + RestartSec=15 in [Service] cause systemd to
restart the minion 15 seconds after a non-clean exit. StartLimitBurst=3

  • StartLimitIntervalSec=300 in [Unit] cap the loop at three restart
    attempts per five minutes so a persistent crash cannot hammer the box.

StartLimitBurst / StartLimitIntervalSec are intentionally placed in
[Unit] — systemd-analyze verify rejects them in [Service] with
Unknown key 'StartLimitIntervalSec' in section [Service], ignoring.,
and [Unit] is systemd's canonical section for these directives.

Merge requirements satisfied?

Commits signed with GPG?

Yes

twangboy
twangboy previously approved these changes Jul 14, 2026
@twangboy

twangboy commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

We are no longer accepting bug fixes on the 3006.x branch. Please rebase against the 3008.x branch.

twangboy
twangboy previously approved these changes Oct 30, 2026
@twangboy twangboy modified the milestones: Argon v3008.5, Argon v3008.7 Oct 30, 2026
@twangboy twangboy linked an issue Oct 30, 2026 that may be closed by this pull request
BrianHa94
BrianHa94 previously approved these changes Nov 10, 2026
dwoz added 2 commits November 24, 2026 01:29
The shipped pkg/common/salt-minion.service systemd unit had no
Restart=/RestartSec=/StartLimit* directives. When the minion crashed
(unhandled exception, worker OOM, etc.) the unit stayed in the failed
state until someone logged in and ran systemctl start salt-minion,
leaving the host offline from the master's point of view for as long
as it took a human to notice.

Ask systemd to restart on failure with a 15-second gap between
attempts and a 3-attempts-in-5-minutes cap so a persistent crash
loop cannot hammer the box. StartLimitBurst and StartLimitIntervalSec
live in [Unit] (systemd rejects them in [Service] with
"Unknown key ... in section [Service], ignoring."); Restart and
RestartSec live in [Service].

Extend the existing static-file audit in
tests/pytests/unit/test_pkg_systemd_units.py (added alongside the
KillMode=mixed fix in saltstack#68406) to assert the new directives are set
and cannot silently regress.

Fixes saltstack#69182
The previous commit set ``StartLimitBurst=3`` inside a 5-minute window
on the salt-minion unit as a crash-loop guard. That ceiling turns out
to be below the number of start requests a normal operator or a CI
``pkg-system-service`` test session can issue within the same window:

  * install-time ``deb-systemd-invoke start``
  * salt-factories ``factory.started()`` fixture start
  * any explicit ``systemctl start`` inside the test body

Combined with the new ``Restart=on-failure``, ``StartLimitBurst=3``
caused the teardown ``systemctl start salt-minion`` in
``test_systemctl_stop_removes_proc_files`` to be refused with
start-limit-hit; the session-scoped ``salt_minion`` fixture then stayed
inactive and every downstream test that targets the minion failed with
"Minion did not return. [No response]" on Ubuntu 24.04 / 26.04,
Debian 13 arm64 and Photon OS 5 arm64 across the 3006.30 / 3007.17 /
3008.5 upgrade matrices.

Raise ``StartLimitBurst`` to 10 (keeping the 300s window). A crashloop
that trips 10 restarts in 5 minutes is still a hard fault systemd
should refuse to keep hammering; the bound is still well below
systemd's own ``DefaultStartLimit`` envelope for a persistent crash.
The existing audit test only requires ``StartLimitBurst > 0``, so the
change is fully compatible with the regression harness added for
saltstack#69182.

Also harden the graceful-stop test teardown with
``systemctl reset-failed salt-minion`` before the recovery start:
this is the systemd-recommended way to clear accumulated start-limit
and failed-state counters when a test intentionally stops+starts the
unit, and keeps the suite resilient if other tests add further
stop/start sequences in the same session.

This branch was previously deployed

1 inactive deployment
ci — 6d38f511 Deployed Nov 24, 2026 by dwoz via Build Onedir Packages / macOS (x86_64) #29592
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.

[Bug]: Minion does not restart after crash

3 participants