-
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
boot, overlord/devicestate, daemon: implement requesting boot into a given recovery system #8369
boot, overlord/devicestate, daemon: implement requesting boot into a given recovery system #8369
Conversation
Implement wrapper for setting up a boot into a given system and mode. The primary use is recovery process, when on a UC20 device we will want to boot into one of the seed systems in a specific mode eg. install, recovery. Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
…h mode Implement support for booting into a given seed system and mode. Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
…de keys THe choice is made by the first bootloader running from ubuntu-seed partition. Make sure to update the right environment. Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
5a28317
to
fd1b0b5
Compare
boot/boot.go
Outdated
@@ -327,3 +327,44 @@ func MarkBootSuccessful(dev Device) error { | |||
} | |||
return nil | |||
} | |||
|
|||
var ErrSystemBootModeUnsupported = errors.New("system boot mode is unsupported") |
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.
Nitpick on naming, ErrUnsupportedSystemBootMode
, this reads better to me.
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.
did a first pass, some comments/questions
boot/boot.go
Outdated
|
||
// bootSystemState is used for choosing the recovery system and mode for the | ||
// next boot. | ||
type bootSystemState interface { |
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.
a bit unclear to me why we need an interface given there is only one impl (the difference should be taken care at the bootloader level)
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.
Yeah, I managed to over complicate things a bit.
boot/boot.go
Outdated
// not supproted by the device, an ErrSystemBootModeUnsupported error is | ||
// returned. | ||
func RecoverySystemInMode(dev Device, systemLabel, mode string) error { | ||
if dev == nil { |
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.
do we do this check in other places?
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.
Hmm not really. Let me drop it in the next push.
boot/bootsystemstate20.go
Outdated
// setup the recovery bootloader | ||
Recovery: true, | ||
} | ||
bl, err := bootloader.Find(InitramfsUbuntuSeedDir, opts) |
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.
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 checked, ubuntu-core-initramfs mounts /run/mnt/ubuntu-seed in RW mode. The core core20 handle-writable-paths sets up a fstab entry that binds mount it to /var/lib/snapd/seed, but still RW mode.
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.
@bboozzoo can you create the bug xnox asked about at the writable-path bits?
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.
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 think we should carry around that directory in run-mode IMHO. OTOH, I don't know where the code should look for to find the ubuntu-seed bootloader, so perhaps it does need to be in this location. However, if we want ubuntu-seed to be in this location, then I think we should rename the InitramfsUbuntuSeedDir to something that isn't specific to the initramfs because this function will be used from places not during the initramfs.
…ary interface Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
…uest-seed-mode-reboot
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
…uest-seed-mode-reboot
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 looks good to me, but I would like to see us resolve the issue about where ubuntu-seed bootloader should actually live to be writable at runtime. Is /run/mnt/ubuntu-seed
okay for this? If so we should rename the InitramfsUbuntuSeedDir
to reflect that this directory exists not just during the initramfs.
Also a small comment on the checks in boot
boot/boot_test.go
Outdated
c.Assert(err, ErrorMatches, "internal error: system or mode is unset") | ||
} | ||
|
||
func (s *bootenvSystem20Suite) TestSetRecoveryBootSystemAndModeRealHappy(c *C) { |
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.
bonus points! I like it 😄
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
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.
overall looks good but there's a small bit that looks wrong, some other suggestions
overlord/devicestate/devicemgr.go
Outdated
} | ||
|
||
logger.Noticef("restarting into system %q for action %q", systemLabel, sysAction.Title) | ||
m.state.RequestRestart(state.RestartSystem) |
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 should use RestartSystemNow right, when available ?
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.
Yes, I hoped to land #8386 quickly, but it seems that PR must reach a decent number of CI restarts before this can happen.
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 PR has landed, I've merged master and pushed the patches that request the new immediate reboot.
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
…uest-seed-mode-reboot
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.
thank you
many: support immediate reboot Our reboot process adds a minimum of 1 minute delay from the request to when the reboot actually happens. This is undesirable in a number of scenarios, specifically when a UC20 install is finished, and when we reboot into a recovery system (once #8369 lands). The PR introduces a new restart type and hooks up the install mode to use the type. Testing this locally in a VM makes the install process feel much faster.
…uest-seed-mode-reboot
…recovery system Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
The PR implements the bits responsible for requesting a boot into a given recovery system & mode.
Part of UC20 recovery chooser work.