Skip to content

46255 fix minion.restart #68225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: 3006.x
Choose a base branch
from

Conversation

barneysowood
Copy link
Collaborator

@barneysowood barneysowood commented Jul 31, 2025

What does this PR do?

Adds support to minion.restart to detect if the minion is running under systemd or the Windows service manager. If so, it will use service.restart to restart the minion rather than killing and attempting to restart it.

If minion_restart_command is set it will follow the old behaviour and use that command to handle the restart.

If minion_restart_command isn't set and systemd/windows aren't detected, preserves the old behaviour of looking at sys.argv and either just killing the minion process or killing it and attempting to restart the process with the same args if -d (for daemon mode) is in sys.argv. Whilst I can see that the former option may be useful if running the minion under another process supervisor, I'm not really sure how the killing and starting the a new process could ever work... I've left it in for the moment, but it should maybe be removed in 3008.

What issues does this PR fix or reference?

Fixes #46255

Previous Behavior

Calling minion.restart on a systemd based system would not work - it would just kill the minion process

New Behavior

Calling minion.restart on a systemd based system will now use service.restart` to restart the minion process.

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

Commits signed with SSH?

Yes

@barneysowood barneysowood force-pushed the 46255-fix-minion-restart branch from 175cf4f to 093e95f Compare July 31, 2025 17:02
Updates minion.restart to use service.restart if system uses systemd or
is a Windows system.

Existing methods don't work if salt-minion is managed by the Windows
service manager or systemd. This adds functionality to check for those
and use service.restart if so.
Adds options to enable use of systemd or windows service to restart the
salt minion. Both options default to True as we should prefer to use
the service managers, but give the option to disable where users are
doing something unusual like running another service supervisor.
Adds unit tests for the minion.restart function to test existing and new
functionality. Also adds tests for helper functions.
Adds support for creating a scheduled job to retry starting the minion
process if it has died and not restarted correctly. This will work on
Windows and systemd based systems.
Adds unit tests for the schedule_retry functionality in the
minion.restart function.

Tests the helper functions that do the scheduling for windows and
systemd, tests the dispatcher function and also testsing the logic in
minion.restart itself.
Refactors minion.restart to move the duplicated code for systemd and
windows into a helper function
@barneysowood barneysowood force-pushed the 46255-fix-minion-restart branch from 7bf9c43 to 189ba1e Compare August 22, 2025 08:55
@barneysowood barneysowood added the test:full Run the full test suite label Aug 22, 2025
@barneysowood
Copy link
Collaborator Author

@dwoz - looks like this passes all the tests when run with test:full ;)

Could you re-add your approval when you get a moment - nothing has changed in the PR.

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.

2 participants