Skip to content
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

Merged

Conversation

bboozzoo
Copy link
Collaborator

The PR implements the bits responsible for requesting a boot into a given recovery system & mode.

Part of UC20 recovery chooser work.

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>
@bboozzoo bboozzoo force-pushed the bboozzoo/uc20-request-seed-mode-reboot branch from 5a28317 to fd1b0b5 Compare March 27, 2020 12:56
boot/boot.go Outdated
@@ -327,3 +327,44 @@ func MarkBootSuccessful(dev Device) error {
}
return nil
}

var ErrSystemBootModeUnsupported = errors.New("system boot mode is unsupported")
Copy link
Collaborator

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.

@mvo5 mvo5 changed the title boot, overlord/devicestate, daemon: boot, overlord/devicestate, daemon: implement requesting boot into a given recovery system Mar 27, 2020
@pedronis pedronis added the Needs Samuele review Needs a review from Samuele before it can land label Mar 28, 2020
Copy link
Collaborator

@pedronis pedronis left a 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 {
Copy link
Collaborator

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)

Copy link
Collaborator Author

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 {
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

// setup the recovery bootloader
Recovery: true,
}
bl, err := bootloader.Find(InitramfsUbuntuSeedDir, opts)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mvo5 @bboozzoo should we actually keep that directory around in run mode though? or should we unmount it and need to remount only when needed? is /var/lib/snapd/seeded at least a RO mount ?

Copy link
Collaborator Author

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.

Copy link
Collaborator

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

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.

boot/boot.go Outdated Show resolved Hide resolved
…ary interface

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
boot/boot.go Outdated Show resolved Hide resolved
boot/boot_test.go Outdated Show resolved Hide resolved
Copy link
Member

@anonymouse64 anonymouse64 left a 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.go Show resolved Hide resolved
boot/boot.go Outdated Show resolved Hide resolved
c.Assert(err, ErrorMatches, "internal error: system or mode is unset")
}

func (s *bootenvSystem20Suite) TestSetRecoveryBootSystemAndModeRealHappy(c *C) {
Copy link
Member

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>
Copy link
Collaborator

@pedronis pedronis left a 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

boot/boot.go Outdated Show resolved Hide resolved
boot/boot_test.go Outdated Show resolved Hide resolved
boot/boot.go Outdated Show resolved Hide resolved
overlord/devicestate/devicemgr.go Outdated Show resolved Hide resolved
boot/boot.go Show resolved Hide resolved
overlord/devicestate/devicemgr.go Outdated Show resolved Hide resolved
}

logger.Noticef("restarting into system %q for action %q", systemLabel, sysAction.Title)
m.state.RequestRestart(state.RestartSystem)
Copy link
Collaborator

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 ?

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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>
@bboozzoo bboozzoo requested a review from pedronis March 31, 2020 18:06
Copy link
Collaborator

@pedronis pedronis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you

bboozzoo added a commit that referenced this pull request Apr 1, 2020
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.
…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>
@bboozzoo bboozzoo merged commit 6b358e7 into snapcore:master Apr 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Samuele review Needs a review from Samuele before it can land
Projects
None yet
4 participants