Skip to content

devicestate: allow auto-refresh when registration is skipped (noregister)#8

Merged
cyberb merged 1 commit into
masterfrom
fix-autorefresh-noregister
Jul 17, 2026
Merged

devicestate: allow auto-refresh when registration is skipped (noregister)#8
cyberb merged 1 commit into
masterfrom
fix-autorefresh-noregister

Conversation

@cyberb

@cyberb cyberb commented Jul 17, 2026

Copy link
Copy Markdown
Member

Problem

Every device that auto-upgraded to snapd 666 stopped auto-refreshing — snap refresh --time shows next: n/a and all snaps freeze at their pre-upgrade revisions. A reboot / systemctl restart snapd does not fix it.

Root cause

canAutoRefresh() (overlord/devicestate/devicestate.go) only allows auto-refresh early when ensureOperationalAttempts >= 3 ("we tried to get a serial for a while, allow refresh anyway"); otherwise it requires a serial, which Syncloud never has (no serial vault).

PR #6 (27b3bb7dce, snapd 666) added the /run/snapd/noregister marker so ensureOperational returns before attempting registration. That leaves ensureOperationalAttempts at 0, so the >= 3 fallback never fires and, with no serial, canAutoRefresh returns false permanently. Before #6 the perpetual "Initialize device" error was ugly, but it bumped attempts past 3 — which is what kept auto-refresh alive.

A reboot doesn't help because the marker is recreated each boot and attempts resets to 0.

Fix

Treat the noregister marker as an explicit opt-out of registration that should still permit auto-refresh, mirroring the marker check already in ensureOperational.

Test

TestCanAutoRefreshNoRegister: seeded + model + no serial + 0 attempts → false; then with the noregister marker present → true.

Rollout

Publish snapd 667 with this fix. Each device's daily platform SnapdUpgradeJob (runs independently of the broken snap auto-refresh) upgrades snapd 666→667, after which auto-refresh resumes and apps catch up. No user action required.

…ter)

canAutoRefresh only returns true early when ensureOperationalAttempts >= 3
("we tried to get a serial for a while, allow refresh anyway"); otherwise it
requires a serial. Syncloud has no serial vault, so before PR #6 snapd kept
attempting registration, failed, and after 3 attempts that fallback enabled
auto-refresh — the perpetual "Initialize device" error was ugly but it is what
kept auto-refresh alive.

PR #6 (snapd 666) added the /run/snapd/noregister marker so ensureOperational
returns before ever attempting registration. That removed the error but left
ensureOperationalAttempts at 0, so the >= 3 fallback never fires and, with no
serial, canAutoRefresh returns false permanently. Every device that upgraded to
snapd 666 stopped auto-refreshing (snap refresh --time shows next: n/a); a
reboot does not help because the marker is recreated each boot and attempts
stays 0.

Treat the noregister marker as an explicit opt-out of registration that should
still permit auto-refresh, mirroring the marker check in ensureOperational.
@cyberb
cyberb merged commit 9ae8352 into master Jul 17, 2026
5 of 8 checks passed
@cyberb
cyberb deleted the fix-autorefresh-noregister branch July 17, 2026 17:42
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