diff options
| author | Michael Vogt <mvo@ubuntu.com> | 2019-10-11 17:14:08 +0200 |
|---|---|---|
| committer | Michael Vogt <mvo@ubuntu.com> | 2019-10-14 12:20:34 +0200 |
| commit | 653595380c82667ca4d0648893bd9f92937ad852 (patch) | |
| tree | 956a7e213292c1e9bf3206d9abd386249d521196 | |
| parent | 6db069eb7eddbc383c1b1c69517ed841eae509ce (diff) | |
snapd: allow installing the snapd snap on UC16snapd-on-uc16
| -rw-r--r-- | overlord/snapstate/snapstate.go | 8 | ||||
| -rw-r--r-- | tests/main/ubuntu-core-snapd/task.yaml | 36 | ||||
| -rw-r--r-- | wrappers/core18.go | 14 |
3 files changed, 48 insertions, 10 deletions
diff --git a/overlord/snapstate/snapstate.go b/overlord/snapstate/snapstate.go index 4f0902e9a4..c3e684b241 100644 --- a/overlord/snapstate/snapstate.go +++ b/overlord/snapstate/snapstate.go @@ -544,14 +544,6 @@ func validateFeatureFlags(st *state.State, info *snap.Info) error { } func checkInstallPreconditions(st *state.State, info *snap.Info, flags Flags, snapst *SnapState, deviceCtx DeviceContext) error { - // Check if the snapd can be installed on Ubuntu Core systems, it is - // always ok to install on classic - if info.GetType() == snap.TypeSnapd && !release.OnClassic { - if deviceCtx.Model().Base() == "" { - return fmt.Errorf("cannot install snapd snap on a model without a base snap yet") - } - } - if err := validateInfoAndFlags(info, snapst, flags); err != nil { return err } diff --git a/tests/main/ubuntu-core-snapd/task.yaml b/tests/main/ubuntu-core-snapd/task.yaml new file mode 100644 index 0000000000..221ae86c17 --- /dev/null +++ b/tests/main/ubuntu-core-snapd/task.yaml @@ -0,0 +1,36 @@ +summary: Test snapd install on a UC16 system + +# snapd snap is already installed by default on uc18+ +systems: [ubuntu-core-16-*] + +execute: | + if [ "$SPREAD_REBOOT" = 0 ]; then + echo "No snapd snap is installed" + not snap list snapd + + echo "Ensure the snapd snap can be installed" + snap install snapd + + echo "And it is considered installed" + snap list snapd + + echo "And snapd from the snap is run in the CGroup" + systemctl status snapd|MATCH "/snap/snapd/[0-9]+/usr/lib/snapd/snapd" + + echo "And after a reboot the snapd snap is still ok" + REBOOT + elif [ "$SPREAD_REBOOT" = 1 ]; then + echo "still installed" + snap list snapd + echo "and running the right snapd" + systemctl status snapd|MATCH "/snap/snapd/[0-9]+/usr/lib/snapd/snapd" + + # we cannot restore in "restore:" because there is the rsync + # snap running there and it will try to refresh the sytem-key + systemctl stop snapd.service snapd.socket + rm -f /etc/systemd/system/snapd.*.{service,timer,socket} + rm -f /etc/systemd/system/*.wants/snapd.*.{service,timer,socket} + systemctl daemon-reload + systemctl start snapd snapd.socket + rsync --help + fi diff --git a/wrappers/core18.go b/wrappers/core18.go index adf95e92fa..0c7c111cc8 100644 --- a/wrappers/core18.go +++ b/wrappers/core18.go @@ -155,6 +155,12 @@ func writeSnapdServicesOnCore(s *snap.Info, inter interacter) error { // enable/start all the new services for _, unit := range changed { + // enable is not idempotent if the symlink target switches + // from /lib to /etc in the multiuser-wantes.d + // so we need to disable first + if err := sysd.Disable(unit); err != nil { + return err + } if err := sysd.Enable(unit); err != nil { return err } @@ -179,8 +185,12 @@ func writeSnapdServicesOnCore(s *snap.Info, inter interacter) error { return err } if isActive { - if err := sysd.Restart(unit, 5*time.Second); err != nil { - return err + // we can never restart the snapd.socket because + // this will also bring down snapd itself + if unit != "snapd.socket" { + if err := sysd.Restart(unit, 5*time.Second); err != nil { + return err + } } } else { if err := sysd.Start(unit); err != nil { |
