overlord, snap: add firstboot state sync #1033

Merged
merged 6 commits into from Apr 18, 2016

Conversation

Projects
None yet
3 participants
Collaborator

mvo5 commented Apr 18, 2016

This branch makes our images work again. It will take what is installed on the system and populate the state with that. This is an intermediate step until we know better how to represent state when using u-d-f. As long as we keep the manifests on disk this will work and is a cheap way for us to unbreak the images and to let people play with snappy 2.0 on devices and images.

mvo5 added some commits Apr 18, 2016

+ var snapst snapstate.SnapState
+ snapst.Sequence = append(snapst.Sequence, &info.SideInfo)
+ snapst.Channel = info.Channel
+ snapst.Active = sn.IsActive()
@pedronis

pedronis Apr 18, 2016

Contributor

this will always be false? unless booted does the right thing with symlinks which maybe it does (don't know order myself)

@mvo5

mvo5 Apr 18, 2016

Collaborator

snappy.FirstBoot() will DTRT and set the active symlink

overlord/firstboot.go
+ return nil
+}
+
+func FirstBoot() error {
@pedronis

pedronis Apr 18, 2016

Contributor

could we have some kind of comment that this a temporary approach/solution

@mvo5

mvo5 Apr 18, 2016

Collaborator

Good point, I will add a comment

cmd/snap/cmd_first_boot.go
@@ -40,7 +41,7 @@ func init() {
}
func (x *cmdInternalFirstBoot) Execute(args []string) error {
- err := snappy.FirstBoot()
+ err := overlord.FirstBoot()
@pedronis

pedronis Apr 18, 2016

Contributor

just return overlord.FirstBoot() given we are not returning the special error, anyway all this is going away so i18n not so important

Collaborator

mvo5 commented Apr 18, 2016

@pedronis thanks a bunch for the review, I addressed the issues.

mvo5 added some commits Apr 18, 2016

"github.com/jessevdk/go-flags"
- "github.com/ubuntu-core/snappy/i18n"
- "github.com/ubuntu-core/snappy/snappy"
+ "github.com/ubuntu-core/snappy/overlord"
)
type cmdInternalFirstBoot struct{}
@niemeyer

niemeyer Apr 18, 2016

Contributor

Can we change that command to be snap internal --firstboot instead of snap firstboot? (not necessarily in this branch)

@mvo5

mvo5 Apr 18, 2016

Collaborator

Sure. Note that this is a hidden command already. I can also move it.

+// This is not the final way we will do the state sync. This is just
+// an intermediate step to have working images again. We need to
+// figure out how we want first-boot to look like.
+func FirstBoot() error {
@niemeyer

niemeyer Apr 18, 2016

Contributor

Can we please move all this logic to overlord/firstboot, under a Booted function? Next (not this branch), we must kill the use of Overlord.Installed and perhaps all use of the snappy package too, and have something like firstboot.Prepare that prepares only the strictly necessary snaps for the first boot without requiring them to be actually installed. Then, Booted will use standard snapstate operations to really install the snaps, out of a pre-defined directory (snapd/firstboot/*.snap?), which will contain kernel, os, and anything else udf puts there.

How does that plan sound?

@niemeyer

niemeyer Apr 18, 2016

Contributor

(changed the snap collection place to be snapd/firstboot/*.snap instead)

@pedronis

pedronis Apr 18, 2016

Contributor

we have already something called booted (that is called on every boot and checks if there was OS failover or not and resyncs what should be the active OS/kernel) which needs to be migrated to the state engine world, so not sure about using that term in the context of first boot logic;

2nd) as we discussed kernel and OS need to be in place to some extent already as far I understand what @mvo5 explained for things to boot at all, so the logic described will work for other snaps but for kernel and os we'll need a bit more work, something slightly different

@pedronis

pedronis Apr 18, 2016

Contributor

I also wonder whether the final place for this won't be under gadgetstate as we discussed many times the idea of having a gadget manager

@niemeyer

niemeyer Apr 18, 2016

Contributor

If we have a "booted" instruction, why do we need a "firstboot" one? Isn't the "firstboot" one the first time the "booted" one runs (which is easy to detect)?

@pedronis

pedronis via email Apr 18, 2016

Contributor
Collaborator

mvo5 commented Apr 18, 2016

I did a manual test of this on a freshly created image and it appears to be working ok and with that images work again.

Contributor

niemeyer commented Apr 18, 2016

Okay, I'm merging this then. Let's discuss and evaluate those suggested improvements tomorrow with more time. We can easily move both the command and where the logic lives without breaking anyone.

@niemeyer niemeyer merged commit 722712c into snapcore:master Apr 18, 2016

3 of 4 checks passed

autopkgtest
Details
Integration tests Success
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage decreased (-0.1%) to 79.159%
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment