-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
systemd service provider does not recognize services that are starting up as 'running' #9426
Comments
Hi Corey, thanks for opening this issue. For whomever picks this up, here is a similar/duplicated Jira ticket for this issue: https://perforce.atlassian.net/browse/PUP-4993 |
Thanks. I don't know if it matters, but I don't seem to have access to that jira issue. I have a login to atlassian and I can authenticate ok, but I get an error:
-Corey |
I had missed a command in the steps to reproduce; fixed now. -Corey |
@bugfood The link above is for internal folks. It's visible publicly read-only as https://puppet.atlassian.net/browse/PUP-4993 |
I'm hoping this could be fixed by adding a third value to the |
Aha, thanks. I agree with your comment in that ticket:
Another consideration is that if puppet considers an 'activating' service to be already 'running', then the startup of that service won't trigger any refreshes within puppet (e.g. for an For systemd, at least, I covered that in my proposal:
This would not exactly fix PUP-4993 as stated, but I think puppet would still do the best thing possible under the circumstances. I don't know how/if that would apply to other service providers; I was only considering the systemd provider to be in-scope for this.
Do you mean this I'm not following what you mean--I think Thanks, |
Describe the Bug
With systemd, a service that is currently running an
ExecStartPre
command will have a unit state ofactivating
. Puppet does not recognize this as any different from when a service is stopped (with a state ofinactive
).If puppet is configured to stop a service via
ensure => 'stopped'
, a service in anactivating
state will remain untouched, potentially starting up at any time afterward, even though it was supposed to be stopped.Expected Behavior
For
ensure => 'stopped'
, puppet should ensure that the service is fully stopped, not in an intermediate state.Steps to Reproduce
Environment
Any recent-ish puppet version should work, up to current git.
Any system with systemd should work, unless older versions of systemd behave differently.
Example 1:
Example 2:
Example 3:
Additional Context
I think the cause of this is the following.
The service provider calls
statuscmd
:puppet/lib/puppet/provider/service/base.rb
Line 71 in 82ad86e
The systemd service provider defines
statuscmd
:puppet/lib/puppet/provider/service/systemd.rb
Line 201 in 82ad86e
The
statuscmd
runs e.g.systemctl is-active -- apache2
; when a service is inactivating
state, the return value is non-zero. The service provider considers anything non-zero to be stopped.The list of possible states appears to be defined here:
https://github.com/systemd/systemd/blob/11d5e2b5fbf9f6bfa5763fd45b56829ad4f0777f/src/basic/unit-def.c#L107
This could probably be fixed by defining a more comprehensive
status
function for the systemd provider.There could be some tricky ramifications, though. For example:
activating
should probably be considered the same as "stopped" when a service isensure => 'running'
. If puppet attempts to start a service that isactivating
, this will be idempotent and return once the service has finished starting up (or fails).activating
should be considered the same as "running". This is necessary in order for puppet to restart (or stop/start) a service, e.g. in order to fix whatever condition caused the service to get stuck inactivating
state.Thanks,
Corey
The text was updated successfully, but these errors were encountered: