Repository navigation
Conversation
When service.running finds the service already running but has to enable or disable it, its normal run reports changes without restarting or reloading the service. A watch requisite then skips mod_watch, because the watching state made changes of its own, so a changed configuration file is not loaded. A dry run still reports that the service would be restarted, because enabling makes no changes in test mode. Set force_mod_watch in this case, so that the state system runs mod_watch as well (saltstack#68960). Starting a service which was not running already loads its configuration, so the flag is not set then. Update the requisites documentation, which described this case as a limitation and recommended splitting service.running and service.enabled into separate states. Fixes saltstack#47361
This was referenced Nov 27, 2026
Contributor
Author
|
BTW, I think this finally addresses one long standing issue with Salt which can now be properly addressed without workarounds one has to document for users to properly do. Now things just work as expected without surprises. |
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?
When
service.runningfinds the service already running but has to enable or disable it, its normal run reports changes without restarting or reloading the service. Awatchrequisite then skipsmod_watch, because the watching state made changes of its own, so a changed configuration file is not loaded.This PR makes
service.runningreturnforce_mod_watch: Truein that case, the opt-in added by #68960, so that the state system runsmod_watchas well. Starting a service which was not running already loads its configuration, so the flag is not set then.It also updates
doc/ref/states/requisites.rst, which described this case as a limitation and recommended splittingservice.runningandservice.enabledinto separate states. The example of a state which opts in now points toservice.runninginstead ofdocker_container.running, which is no longer part of Salt.This change targets master because #68960 exists only there. The related fixes in #70972 remove
force_mod_watchfrom state results; without them, a run which only enables the service shows the key in its result.What issues does this PR fix or reference?
Fixes #47361. It was closed as not planned in October 2026, so I ask to reopen it.
Related issues, closed without a fix: #59688 (closed as expected behavior because of the requisites rule which #68960 made opt-in), #54952 and #55098.
Previous Behavior
When
httpdis running but disabled and the configuration file changes, the service is enabled but not restarted, so the new configuration is not loaded. A dry run (test=True) reports "Service is set to be restarted", which the real run then does not do.New Behavior
The service is enabled and restarted (or reloaded with
reload: True). A service which was already enabled, and a service which was not running, behave as before.Tested on master with systemd as PID 1 (Ubuntu 24.04 container) and a test unit, detecting restarts with the unit's
InvocationID:With
reload: Trueand a unit whoseExecReloadrecords each reload, the first case enables the service and reloads it once, without restarting it (its start time stays the same). Without this PR it is neither reloaded nor restarted.Merge requirements satisfied?
[NOTICE] Bug fixes or features added to Salt require tests.
doc/ref/states/requisites.rstand the module documentation ofsalt/states/service.py.changelog/47361.fixed.md.tests/pytests/unit/states/test_service.py, and a functional test intests/pytests/functional/states/test_service.pywhich enables a running service while a watched file changes and checks withExecMainStartTimestampMonotonicthat systemd restarted it. With systemd andcronas root, all 4 functional service tests pass, and the new one fails without this change.Commits signed with GPG?
Yes