Skip to content

Auto-upgrade snapd daily at 11:00 (opposite snapd's refresh window)#755

Open
cyberb wants to merge 1 commit into
masterfrom
snapd-auto-upgrade
Open

Auto-upgrade snapd daily at 11:00 (opposite snapd's refresh window)#755
cyberb wants to merge 1 commit into
masterfrom
snapd-auto-upgrade

Conversation

@cyberb

@cyberb cyberb commented Jul 7, 2026

Copy link
Copy Markdown
Member

What

Adds a cron SnapdUpgradeJob that automatically upgrades the snapd daemon once a day at 11:00, deliberately opposite snapd's own nightly refresh window (23:00~24:00/1).

Why

On Syncloud, snapd is an out-of-band host binary (extracted from a tarball into /usr/lib/snapd), not a snap. So snapd's auto-refresh timer refreshes the platform base snap and app snaps nightly, but never upgrades the snapd daemon itself — that only happened via the manual POST /rest/installer/upgrade button.

This closes that gap while avoiding the genuinely risky alternative of packaging snapd as a self-refreshing snap (a daemon replacing its own running binary during the refresh window).

How

Every 5-min cron tick, the job checks SimpleScheduler.ShouldRun(day=0, hour=11, …). When it fires it compares:

  • store version: apps.syncloud.org/releases/<channel>/snapd2.version
  • installed version: snapd /v2/system-info

and if they differ, runs the existing tarball upgrade through JobMaster.Offer("installer.upgrade", …) — the same serialized path the manual button uses, so it can't race an app install or manual upgrade. On a busy JobMaster it retries within the hour; otherwise it runs at most once per day.

11:00 keeps the snapd stop/swap/restart clear of the 23:00–24:00 window (so it never overlaps snapd applying a platform/app refresh) and surfaces a bad upgrade during the day rather than overnight.

Notes / follow-ups

  • Registered the installer.Installer singleton before the new job (golobby resolves singletons eagerly).
  • Not in this PR, worth doing next: upgrade.sh currently cps over the live binary with no rollback or post-restart health check. Now that it runs unattended, adding backup + rollback + a snap --version/system-info health check would make a failed auto-upgrade self-recovering.

Test

go test ./cron/... ./ioc/... ./job/... pass. Pre-existing identification/network test failures are environmental (Termux sandbox netlink/proc), unrelated to this change.

snapd on Syncloud is an out-of-band host binary (installed from a tarball
into /usr/lib/snapd), not a snap, so snapd's own auto-refresh timer never
upgrades the snapd daemon itself. Until now the only way to pick up a new
snapd was the manual POST /rest/installer/upgrade button, while the platform
base snap and app snaps auto-refresh nightly (defaultRefreshScheduleStr
"23:00~24:00/1" in the snapd fork).

Close that gap with a cron job that, once a day at 11:00, compares the store
snapd version (apps.syncloud.org/releases/<channel>/snapd2.version) against
the installed version and, if they differ, runs the existing tarball upgrade
via JobMaster ("installer.upgrade") — the same serialized path the manual
button uses, so it can't race an app install or a manual upgrade.

11:00 is chosen as the opposite of the 23:00-24:00 refresh window so the
snapd swap never overlaps snapd applying a platform/app refresh, and a bad
upgrade surfaces during the day rather than overnight.

Registering the installer.Installer singleton before the new job because
golobby resolves singletons eagerly at registration time.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant