-
Notifications
You must be signed in to change notification settings - Fork 562
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
wrappers,tests: restart always enabled units #12670
wrappers,tests: restart always enabled units #12670
Conversation
a1fda5d
to
1a7cce5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, as we discussed we should check if there is any intersection with the behavior around handling services during refreshes, I suspect not, but worth double checking
Refreshes do "stop-snap-services" and later a "start-snap-services". The former takes a list of the disabled services, not considering the running state. The latter restart the snap services but those in the list previously considered, so it looks like that behavior is already coherent with this PR. RestartServices is called when doing a "snap restart" and when quota configuration is changed. For the latter, maybe the new behavior changes things (I do not know how automatic are these restarts) - cc @Meulengracht as maybe he can comment. |
I checked up on how we restart services in quota groups, and we do this when moving snaps in and out of service groups, were we restart services for that snap. It will of course change the behaviour, but I don't see this as an issue for the quota case. |
are we saying that now changing a quota group might restart services that were enabled but not running? it sounds like we might need different behavior for that vs snap(ctl) restart requests? |
Yes, to me it sounds like that too. Restarting when moving snaps across quota groups sounds like something transparent to the user that should respect the current state of the processes, which is different from requiring a restart from API. |
I've added now a flag to discriminate between restarting active services or not. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question about the signature change vs consistency, otherwise this looks reasonable
wrappers/services.go
Outdated
@@ -1804,7 +1808,7 @@ type RestartServicesFlags struct { | |||
// TODO: change explicitServices format to be less unusual, more consistent | |||
// (introduce AppRef?) | |||
func RestartServices(svcs []*snap.AppInfo, explicitServices []string, | |||
flags *RestartServicesFlags, inter Interacter, tm timings.Measurer) error { | |||
flags RestartServicesFlags, inter Interacter, tm timings.Measurer) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change is a bit strange because now StopService and StartServices are inconsistent, I would leave things as they were
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've reverted this part. In general I would prefer to force having to pass the parameter as it is more explicit and avoids checks for nil, but as things are the same for StopServices
I guess that should be its own PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks
678971c
to
08da779
Compare
History rewritten with no code changes |
I've pushed now changes to fix the spread failures. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
questions
// RestartOnlyActive is only for "restart" and "reload-or-restart" | ||
// actions, and when set it restarts only the active services, that is, | ||
// enabled non-running services are ignored. | ||
RestartOnlyActive bool `json:"restart-only-active,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the default of this is wrong for tasks that were made by old snapd though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, but I'm not sure on the concern here, tasks from older changes would have been already run by the old snapd, and anyway we are changing behavior, it does probably not matter if it affects a task created before snapd refreshes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
independent changes might be running while we update snapd, and it matters again if the tasks were about quota groups, I fear we need to make the default be the old behavior and deal with that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've reverted the flag now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
more comments
Action: "restart", | ||
SnapName: info.InstanceName(), | ||
Services: getServiceNames(servicesAffected[info]), | ||
RestartEnabledNonActive: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here we know we want false, but I suspect that there maybe other places where we want to set this to true? where do we also create ServiceAction tasks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I forgot to change that, I've pushed changes to fix it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thx
Due to a previous decision [1] we were not restarting any non-running unit, this commit changes that back so non-running units are not restarted only if the unit is also disabled. This way, stopping and restarting works more similarly to how it is usually expected. Fixes LP#2012630. [1] https://forum.snapcraft.io/t/command-line-interface-to-manipulate-services/262/46
Now all enabled services are restarted.
f80cdb6
to
c6ba5f9
Compare
History rewritten and re-pushed now |
Due to a previous change we were not restarting any non-running unit, but actually that should happen only if the unit is also disabled. Otherwise, stopping and the restarting will not work. Fixes LP#2012630. For reference, see [1], which looks like it might have been misinterpreted.
[1] https://forum.snapcraft.io/t/command-line-interface-to-manipulate-services/262/46