The purpose of this thread is to propose a more robust method for snapd to handle installation and post-installation runs. This can be valid for any situation where snapd is not part of the base system configuration (e.g.: certain non-Ubuntu distributions), the system base state configuration is unknown, or the system state has changed (e.g.: updates).
Installation
There are two levels of checks:
- Pre-install sanity checks for platform and/or system compatibility.
- Post-install sanity checks to verify that all components work and communicate correctly.
The implementation of the checks ought to be independent of snapd, e.g.: shell script, to avoid any cyclic dependency on snapd checking itself. The checks can then be implemented for each step in the snapd stack.
Pseudo-code
if !“supported platform” - warn|exit
if !“apparmor + necessary kernel modules” - fix|warn|exit
if !“necessary libraries/systemd/daemons” - fix|warn|exit
if !“network/socket/etc” - fix|warn|exit
if !“other capabilities - disk/permissions” - fix|warn|exit
if !“core/core18/etc” - fix|warn|exit
if !“dummy run” - fix|warn"exit
First run (and potentially any arbitrary run)
The second part is a possible chicken & egg problem where the system state changes from the state it was during the snapd installation and now prevents snapd from working correctly.
There are two possible options:
- Try to run and fail - this means snapd provides an error from within the context of itself. This means that if snapd cannot run or execute some of its code, the errors may not be complete.
- Bootstrap snapd execution with a tiny statically compiled checker/shim, which runs the basic checks (we can define what this subset must or needs be) and then “hands” over to the service itself. This means we can reliably inspect system state.
Pseudo-code:
start checker
check conditions abc (e.g. socket, disk space, permissions).
if conditions=true, jump to main snapd code.
if conditions=false, warn|exit OR
if conditions=false, jump to healer code
healer code = same set of instructions we do for the installation
Ideas, thoughts, etc?