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.
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
feat: make shutdown action return meaningful exit code #336
feat: make shutdown action return meaningful exit code #336
Changes from 1 commit
c64cb8f
e9ab412
d6240c7
061d073
d2e3bfe
4b1ece0
9d37a88
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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 believe the previous behaviour was that both a
RestartDaemon
andRestartSystem
resulted in issuing adoReboot
here (both set therestartSystem
flag). I believe this meant that previously any service that had ashutdown
action would have causedshutdown -r
command to run (and would block here withtime.Sleep(waitTimeout)
for that to issue a system reboot). Just checking this is intended, because without the reboot action theRestartDaemon
restart type would need help from systemd (and therefore needs it) to restart the daemon.After the change this is now again aligned with how snapd uses RestartDaemon, but of course they render on systemd for everything.
(For KernOS this means that as PID1 we will actually now exit the process, and as a result cause a kernel panic. This is not necessarily a problem, since our kernels are configured to reboot on any PID1 exit).
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 believe this is incorrect, as Go's
case
statement doesn't fall through by default (like C's). That said, I've shuffled the code a little bit to be a bit more like snapd's and as a result it's a bit clearer they're different cases.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.
Oh no Fred. Well this was the only worry I had, while not understanding why the code does not match my experience. Merge away!
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.
Just sharing my mind here - maybe something we can boldly try to clean up a bit in the future ?
The
RestartType
name has evolved over time it seems to no longer work very well. The fact that we start the type withRestart
prefix also does not help make this easy to follow. Seems like the meaning of many of these options are overloaded depending if you take the wider system effect into place (where systemd exists, and will restart Pebble on exit, or not).My view is this list tries to sometimes include 3 things:
Action, Scope and now also Reason (while having a prefix called Restart)
However, I cannot see an easy way to clean this up without mayor surgery (I read your spec considerations). In an ideal world, I would have referred to this group of actions and the package as
shutdown
(like the command), and perhaps a simpler list of options: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 don't disagree this is quite messy! However, I'm going to leave it for future work.
I've made a couple of tweaks to make the code a bit more like snapd's (which is even messier as it has more cases :-), for example renaming the field to
requestedRestart
.