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
Add start_after_enable
property to systemd_unit
resource
#14188
base: main
Are you sure you want to change the base?
Conversation
It is a common operational task is to start a service after enabling it. systemd even has a flag for this (`--now`). I didn't see a way to cleanly add that flag in the implementation so I added an explicit start. Note this feature is different than the `:start` action which always starts the service. A `stop_after_disable` property may also be useful.
Quality Gate passedKudos, no new issues were introduced! 0 New issues |
@adsr Hi, can you please add a DCO to this. This looks great, thanks for the feature. We're going to review this at the community meeting next week. Can you attend? It's at 1 PST on Tuesdays. https://progress.zoom.us/j/94141161621?from=addon |
@dafyddcrosby May have some suggestions on the |
Glad others are also thinking about this! :-D You'd mentioned the What I like about One way to sidestep the systemd version issue, AND get the intended atomicity, AND save an extra resource would be to create |
This current implementation doesn't really add anything than defining the service with Which means once systemd has exhausted the tries in the unit, next chef run won't try to get it started again and it will stay dead in the water until someone get on the system to start it manually. If that's the desired behavior then something like:
Should achieve the same thing as this PR and is more explicit about how it behaves IMHO. |
Assuming you're running chef-client on a cron, The Naming it |
Well, that's kinda breaking the promise theory if you're not describing a desired state but a workflow of actions. re: "but of course it would cause the service to start if anything in the resource changed" This recipe wouldn't have this side effect:
This should behave as you're aiming, but that's clearly creating an unpredictable state for your node at the end as you can never be sure the unit is started or not and what version the service is using. This goes against the idea of describing a desired state IMHO. If merged, I would prefer a Implementing the |
OK there was much discussion in the week's meeting about this. We came to a few conclusions:
So, if the goal is to improve performance with less shellouts, then the new actions ( If the goal is just to have a single action that does two things, that's an anti-pattern, and we'd rather not introduce that - in reality the user is requesting two states of their system: that a service be enabled, and that a service be started, and it should be two actions. The only reason for bucking that pattern is to halve the number of shellouts for those who are trying to eek out as much performance as possible (e.g. Meta would benefit from it). |
Description
It's a common operational task is to start a service after enabling it. systemd has a flag for this (--now). I didn't see a way to cleanly add that flag in the implementation so I added an explicit start.
Note this feature is different than the
:start
action which always starts a service.A
stop_after_disable
property may also be useful.Related Issue
#14187
Types of changes
Checklist:
Gemfile.lock
has changed, I have used--conservative
to do it and included the full output in the Description above.