The road to core18
This document outlines what needs to be done to have a working
Ubuntu Core 18 system from a fresh image and from an upgrade.
Current status (2018-08-02)
- snapd snap in “edge”
- bootable core18 snap in “edge”
- ubuntu-image can create core18 images with 4.15 kernels
- core18 images boot and can install/run all snaps from core16 and core18
- snapd test suite runs on core18 (almost all tests that make sense)
- kernel track policy is checked inside snapstate
- implicit/system interfaces translated from snapd -> core internally and visible as “system” in the cli/API
Fresh image
A fresh image is created by ubuntu-image
from a new model
assertion obtained via:
$ snap known --remote model series=16 brand-id=canonical model=core-amd64-18
This model assertion will contain the new entry “base: core18” that
identifies what base snap is used for booting and the new “kernel: pc-kernel=4.15” entry that specifies the kernel and the kernel track.
Partition layout
The partition layout will be:
- (optional) EFI
- system-boot
- writable
The same “writable” setup [XXX: should this be document just
like the boot modes] will be used to make parts of /etc and
/var writable as for Ubuntu Core (16). Core18 will stop using
“synced” directories though and the amount of writeable dirs
will shrink as much as possible.
Snaps
The Ubuntu Core 18 amd64 system will consist of the following
snaps:
- core18 (base snap, no snapd)
- {pi2,pc,…}-kernel (kernel snap)
- {pi2,pc,…} (gadget snap)
- snapd (app snap with snapd)
The system will use the same boot robustness protocol as
before (described in Ubuntu Core boot modes)
with the “snap_core” variable set to “core18_XYZ.snap”.
The difference between this and the previous Ubuntu Core system
is that core18 will not contain snapd. This is nice because it
de-couples snapd from core so we can rebuild them independently
and also maintain them by different teams. It also provides some
challenges because now we need to solve the firstboot bootstrap
problem on how to install the snapd snap without having a snapd
available (see #### Bootstrap section below).It also means we
need to consider how to expose snapd (see #### The snapd snap).
The kernel snap has the same name as in core16 and we will
move it into a track (4.15).
Base snaps
The model assertion supports a new “base: some-base” field. If ubuntu-image seeds this field it will automatically put snapd in such images. A base snap has some minimal requirements:
- some mount points like /usr/lib/snapd must exist
- /snap/bin must be in the default PATH (e.g. via /etc/environment)
- Right now a bootstrap script is required to start snapd once - this will probably change and gets integrated into ubuntu-image (i.e. ubuntu-image will pull a generic bootstrap script out of the snapd snap and into the image).
The snapd snap
The snapd snap is a special snap. It is available in the “edge” channel right now and build daily from git master.
It is currently only installable on systems that use “base: something” in their model assertion (which means only on core18 at this point). Eventually we will make it available to core16 and classic systems and it will be used for re-exec there.
We will most likely invent a new snap type for it “type: snapd” (but this is not done yet).
It has no base because it needs to work with multiple bases (i.e. it needs to work on core16,core18,etc). This means we need to make sure its as self-contained as possible.
The core18 snap
The core18 snap is build together with the ubuntu foundations team at https://github.com/snapcore/core18.
The bootable version of core18 is available in the “edge” channel and its currently around 50Mb (down from 90Mb on core16).
Right now core18 will run /snap/snapd/current/usr/lib/snapd/snapd.run-from-snap to generate all the right snapd units. However this will change so that snapd writes the right unit files directly (and /snap/bin/snap).
Today core18 contain a symlink from /usr/bin/snap to /snap/snapd/current/usr/bin/snap currently.
The snapd snap failover plan is:
- Always write the sequence information for snaps into /var/lib/snapd/sequence/name.json so that simpler can inspect the snap install sequence without needing to read the full state
- Use the “OnFailure=” feature of systemd that triggers a snapd.failure unit
- The snapd.failure unit will read the sequence file and start the previous snapd
- The previous snapd will detect if the error happend during a snapd refresh and in this case revert the refersh
This ensures that we can always go back to a snapd version that was able to do refrehes.
Bootstrap
A fresh Ubuntu Core 18 system will boot without an installed snapd.
The core18 (and other base snaps) contains a special script that will do the bootstrap if no /snap/snapd/* snap is mounted. In this case the script will search /var/lib/snapd/seed/ for a snapd snap, mount that, run snapd and it is expected that snapd will seed itself and restart into the fully installed snapd snap once the seeding is far enough to have the snapd snap.
Interfaces
All implicit interfaces (the ones that are currently put on “core”) will be put onto “snapd” on core18 systems.
The recommendations is that people should use the new “system” alias to refer to implicit interfaces.
Work items (fresh image):
-
robustness for bad snapd updates (similar logic as for the bootloader base/core/kernel rollbacks) (https://github.com/snapcore/snapd/pull/5592)
-
make core-{amd64,i386,pi2,pi3,dragonboard}-18 model assertions with
base: core18
andkernel: xxx-kernel=4.15
-
hide bases by default from
snap list
(but show withsnap list --all
) -
cleanup unused bases (if nothing needs them anymore)
-
cleanup snapd snap
-
solve system config being stored under “core” (new systems and later upgrade)
-
look into shrinking the core18 image
Upgrade from core to core18
The goal is to have a painless upgrade from existing Ubuntu Core 16 machines to Ubuntu Core 18. The upgrade will not happen automatically, it needs to be triggered via a manual process.
Because the partition layout and the writable-path handling does not change the upgrade is possible. We need to ensure any uid/gid mapping in core16 is also compatible with core18.
Work items (preliminary)
- specify what process/command the user needs to run to upgrade
- the existing model assertion will get a new field:
supported-transition:
which will allow to specify what new models this machine may become - snapd will need code to deal with the model change and trigger the right refreshes
- we need to support reverts and deal with fail-overs (like the new kernel not booting etc).