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

Draft
wants to merge 4 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

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant