-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix race condition in service.running on systemd
This state will check if the service is running after it runs a `service.start` on it. However, systemd has more potential states than just up or down. It also has the concept of `activating` and `deactivating` states. An example of this are services which use `Type=notify`, and rely on the service to tell systemd that it is up. For these services, `systemctl start` will exit (ceding control back to Salt) and systemd will await its notification. In that interim, the service will be in either the `activating` or `deactivating` state. Importantly, Salt uses `systemctl is-active service_name` to check if the service is up, and any state other than `active` results in a nonzero exit code, which Salt interprets as the service being down. So, if the notification doesn't come quick enough, then when Salt checks on the service's status post-start, it will appear to Salt to be down when it is actually in the `activating` state. This commit modifies the `systemd_service` module such that, when the status is `activating` or `deactivating`, the `systemctl is-active` will be periodically retried, up to a tunable amount of time (by default 3 seconds), until some result other than `activating` or `deactivating` is returned (or the timeout is reached, at which time the service will be assumed to be down). This will keep services from being misinterpreted as being dead when it just took a little longer than normal to start. I realize that there is already an `init_delay` argument for this state, but this _always_ sleeps for that period of time, and also applies to all `service` modules. The idea behind making changes to the `systemd_service` module is to catch many issues like this _before_ you have to start troubleshooting why it's being identified as dead when it's not actually dead. I'm open to suggestions.
- Loading branch information
Erik Johnson
committed
Jan 2, 2020
1 parent
be5811e
commit 4136ca7
Showing
4 changed files
with
155 additions
and
36 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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