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

many: move firstboot code into the snapd daemon #2033

Merged
merged 55 commits into from
Oct 6, 2016
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
564b0a0
Remove snapd.firstboot.service
mvo5 Sep 28, 2016
a23ceeb
move firstboot to devicemgr.go:ensureOperational
mvo5 Sep 28, 2016
f55dee1
Move firstboot code into the daemon
mvo5 Sep 28, 2016
399dc3a
UpdateRevision only needs to run once per boot (thanks to Pedronis)
mvo5 Sep 29, 2016
4f3c74e
populate the state in the manager tests
mvo5 Sep 29, 2016
6bc384f
Merge remote-tracking branch 'upstream/master' into feature/no-more-f…
mvo5 Sep 29, 2016
d9d83fc
add missing ensure-before
mvo5 Sep 29, 2016
aeed21f
add missing FIXME
mvo5 Sep 29, 2016
ebfe992
fix firstboot tests
mvo5 Sep 29, 2016
b1b6207
make booted almost work
mvo5 Sep 29, 2016
e742175
fix checkSnap() and firstboot
mvo5 Sep 29, 2016
dfc62a6
remove merge artifact
mvo5 Sep 29, 2016
0808919
remove more firstboot.service bits
mvo5 Sep 29, 2016
c645f22
Merge remote-tracking branch 'upstream/master' into feature/no-more-f…
mvo5 Sep 30, 2016
eec02c9
fix firstboot assertion test
mvo5 Sep 30, 2016
f546e75
Merge remote-tracking branch 'upstream/master' into feature/no-more-f…
mvo5 Sep 30, 2016
9adba01
add debug for suite failure
mvo5 Sep 30, 2016
a565297
add loop into firstboot-assertion work
mvo5 Oct 1, 2016
b84ec73
review feedback
mvo5 Oct 1, 2016
d24a727
drop check_snap test for gadget for now
mvo5 Oct 1, 2016
e622f83
Merge remote-tracking branch 'upstream/master' into feature/no-more-f…
mvo5 Oct 2, 2016
7ad072b
add missing "fmt" import
mvo5 Oct 2, 2016
6203394
use ref.String() instead the cicrular dependency error
mvo5 Oct 2, 2016
aa004a5
fix wait for seed changes in firstboot-assertions
mvo5 Oct 2, 2016
e5733bf
fix prepare-image-grub test
mvo5 Oct 2, 2016
08de3bf
add wait for firstboot
mvo5 Oct 2, 2016
61ec540
add debug line
mvo5 Oct 2, 2016
842153c
add debug for ubuntu-core-update-rollback-stresstest
mvo5 Oct 2, 2016
ca47dbb
move update-revisions back into "booted" service to avoid race
mvo5 Oct 2, 2016
36acdfa
move update-revisions back into "booted" service to avoid race
mvo5 Oct 2, 2016
7a66cba
fix botted test
mvo5 Oct 2, 2016
dfd7f85
add missing cat
mvo5 Oct 2, 2016
dd952de
Merge remote-tracking branch 'upstream/master' into feature/no-more-f…
mvo5 Oct 3, 2016
7497386
Merge remote-tracking branch 'upstream/master' into feature/no-more-f…
mvo5 Oct 4, 2016
cc3aab1
Merge remote-tracking branch 'upstream/master' into feature/no-more-f…
mvo5 Oct 4, 2016
0ba17b9
Merge remote-tracking branch 'upstream/master' into feature/no-more-f…
mvo5 Oct 5, 2016
7714468
add seeded flags to the snapstate
mvo5 Oct 5, 2016
774d84f
add comment about cmd_first_boot.go
mvo5 Oct 5, 2016
787620c
move boot-ok into the daemon as well
mvo5 Oct 5, 2016
5c9ff09
simplify seeded flag setting
mvo5 Oct 5, 2016
7ad0a55
address review feedback
mvo5 Oct 5, 2016
be6db86
extract changeInFlight helper
mvo5 Oct 5, 2016
6fe3cf1
add new "mark-seeded" task
mvo5 Oct 5, 2016
f5e92ec
fix PopulateStateFromSeed() tests
mvo5 Oct 6, 2016
e6587f4
do not ignore missing assertions/ dir
mvo5 Oct 6, 2016
f8253ab
add tests for ensureSeedYaml
mvo5 Oct 6, 2016
2d11604
add tests for ensureBootOk
mvo5 Oct 6, 2016
9e0ca19
address review feedback
mvo5 Oct 6, 2016
2550642
address review feedback
mvo5 Oct 6, 2016
aab57b9
run m.ensureBootOk() only once instead of everytime Ensure() is called
mvo5 Oct 6, 2016
7d10dca
simplify UpdateRevisions()
mvo5 Oct 6, 2016
9c6834e
ensure mark-seeded task run is tested
mvo5 Oct 6, 2016
bad822f
rename snapstate.UpdateRevisions -> snapstate.UpdateBootRevisions
mvo5 Oct 6, 2016
4a5f9f3
put bootOkRan test only around MarkBootSuccessful
mvo5 Oct 6, 2016
eb61a05
move "mark-seeded" back into devicemgr.go
mvo5 Oct 6, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion asserts/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (f *fetcher) chase(ref *Ref, a Assertion) error {
case fetchSaved:
return nil // nothing to do
case fetchRetrieved:
return fmt.Errorf("internal error: circular assertions are not expected: %s %v", ref.Type.Name, ref.PrimaryKey)
return fmt.Errorf("internal error: circular assertions are not expected: %s", ref)
}
if a == nil {
retrieved, err := f.retrieve(ref)
Expand Down
32 changes: 6 additions & 26 deletions cmd/snap/cmd_booted.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ import (
"fmt"

"github.com/jessevdk/go-flags"

"github.com/snapcore/snapd/i18n"
"github.com/snapcore/snapd/overlord"
"github.com/snapcore/snapd/overlord/boot"
"github.com/snapcore/snapd/partition"
"github.com/snapcore/snapd/release"
)

type cmdBooted struct{}
Copy link
Collaborator

Choose a reason for hiding this comment

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

needs the same kind of comment as firstboot?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, added that.

Expand All @@ -43,28 +37,14 @@ func init() {
cmd.hidden = true
}

// WARNING: do not remove this command, older systems may still have
// a systemd snapd.firstboot.service job in /etc/systemd/system
// that we did not cleanup. so we need this dummy command or
// those units will start failing.
func (x *cmdBooted) Execute(args []string) error {
if len(args) > 0 {
return ErrExtraArgs
}

if release.OnClassic {
fmt.Fprintf(Stdout, i18n.G("Ignoring 'booted' on classic"))
return nil
}

bootloader, err := partition.FindBootloader()
if err != nil {
return fmt.Errorf(i18n.G("cannot mark boot successful: %s"), err)
}

if err := partition.MarkBootSuccessful(bootloader); err != nil {
return err
}

ovld, err := overlord.New()
if err != nil {
return err
}
return boot.UpdateRevisions(ovld)
fmt.Fprintf(Stderr, "booted command is deprecated")
return nil
}
38 changes: 0 additions & 38 deletions cmd/snap/cmd_booted_test.go

This file was deleted.

12 changes: 8 additions & 4 deletions cmd/snap/cmd_first_boot.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
package main

import (
"github.com/jessevdk/go-flags"
"fmt"

"github.com/snapcore/snapd/overlord/boot"
"github.com/jessevdk/go-flags"
)

type cmdInternalFirstBoot struct{}
Expand All @@ -36,10 +36,14 @@ func init() {
cmd.hidden = true
}

// WARNING: do not remove this command, older systems may still have
// a systemd snapd.firstboot.service job in /etc/systemd/system
// that we did not cleanup. so we need this dummy command or
// those units will start failing.
func (x *cmdInternalFirstBoot) Execute(args []string) error {
if len(args) > 0 {
return ErrExtraArgs
}
Copy link
Contributor

@niemeyer niemeyer Oct 2, 2016

Choose a reason for hiding this comment

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

Would be good to have a comment here saying why we cannot remove this file, so we resist the temptation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added that too.


return boot.FirstBoot()
fmt.Fprintf(Stderr, "firstboot command is deprecated")
return nil
}
16 changes: 0 additions & 16 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,10 @@ ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
endif

override_dh_systemd_enable:
# enable boot-ok
dh_systemd_enable \
-psnapd \
snapd.boot-ok.service
# enable auto-import
dh_systemd_enable \
-psnapd \
snapd.autoimport.service
# enable the first boot service
dh_systemd_enable \
-psnapd \
snapd.firstboot.service
# we want the auto-update timer enabled by default
dh_systemd_enable \
-psnapd \
Expand All @@ -94,10 +86,6 @@ override_dh_systemd_enable:
snapd.service

override_dh_systemd_start:
# start boot-ok
dh_systemd_start \
-psnapd \
snapd.boot-ok.service
# we want to start the auto-update timer
dh_systemd_start \
-psnapd \
Expand Down Expand Up @@ -157,11 +145,7 @@ override_dh_install:
install --mode=0644 debian/*.socket debian/snapd/$(SYSTEMD_UNITS_DESTDIR)
install --mode=0644 debian/snapd.service debian/snapd/$(SYSTEMD_UNITS_DESTDIR)
install --mode=0644 debian/*.target debian/snapd/$(SYSTEMD_UNITS_DESTDIR)
install --mode=0644 debian/snapd.boot-ok.service debian/snapd/$(SYSTEMD_UNITS_DESTDIR)
install --mode=0644 debian/snapd.firstboot.service debian/snapd/$(SYSTEMD_UNITS_DESTDIR)
ifeq ($(RELEASE),trusty)
dh_link debian/snapd/$(SYSTEMD_UNITS_DESTDIR)/snapd.firstboot.service debian/snapd/$(SYSTEMD_UNITS_DESTDIR)/multi-user.target.wants/snapd.firstboot.service
dh_link debian/snapd/$(SYSTEMD_UNITS_DESTDIR)/snapd.boot-ok.service debian/snapd/$(SYSTEMD_UNITS_DESTDIR)/multi-user.target.wants/snapd.boot-ok.service
dh_link debian/snapd/$(SYSTEMD_UNITS_DESTDIR)/snapd.service debian/snapd/$(SYSTEMD_UNITS_DESTDIR)/multi-user.target.wants/snapd.service
dh_link debian/snapd/$(SYSTEMD_UNITS_DESTDIR)/snapd.autoimport.service debian/snapd/$(SYSTEMD_UNITS_DESTDIR)/multi-user.target.wants/snapd.autoimport.service
endif
Expand Down
10 changes: 0 additions & 10 deletions debian/snapd.boot-ok.service

This file was deleted.

16 changes: 0 additions & 16 deletions debian/snapd.firstboot.service

This file was deleted.

1 change: 0 additions & 1 deletion debian/snapd.frameworks-pre.target
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@

[Unit]
Description=Ready for frameworks
After=snapd.firstboot.service
After=cloud-init.service

2 changes: 1 addition & 1 deletion debian/snapd.refresh.service
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[Unit]
Description=Automatically refresh installed snaps
After=network.target snapd.firstboot.service snapd.socket
After=network.target snapd.socket
Requisite=snapd.socket
ConditionPathExistsGlob=/snap/*/current
Documentation=man:snap(1)
Expand Down
3 changes: 0 additions & 3 deletions debian/snapd.service
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
[Unit]
Description=Snappy daemon
#FIXME: snappy on ubuntu does not have a snapd.firstboot snap installed
#After=snapd.firstboot.service
Before=snapd.frameworks-pre.target
Requires=snapd.socket

[Service]
Expand Down
7 changes: 1 addition & 6 deletions dirs/dirs.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ var (
SnapAssertsDBDir string
SnapTrustedAccountKey string

SnapStateFile string
SnapFirstBootStamp string
SnapStateFile string

SnapBinariesDir string
SnapServicesDir string
Expand Down Expand Up @@ -127,10 +126,6 @@ func SetRootDir(rootdir string) {
SnapSeedDir = filepath.Join(rootdir, snappyDir, "seed")
SnapDeviceDir = filepath.Join(rootdir, snappyDir, "device")

// NOTE: if you change stampFile, update the condition in
// snapd.firstboot.service to match
SnapFirstBootStamp = filepath.Join(rootdir, snappyDir, "firstboot", "stamp")

SnapBinariesDir = filepath.Join(SnapMountDir, "bin")
SnapServicesDir = filepath.Join(rootdir, "/etc/systemd/system")
SnapBusPolicyDir = filepath.Join(rootdir, "/etc/dbus-1/system.d")
Expand Down
87 changes: 0 additions & 87 deletions firstboot/firstboot.go

This file was deleted.