Skip to content

Guard trixie-next on Bullseye/Bookworm and return to compatible Release - #4341

Open
kevinwieland wants to merge 3 commits into
openWB:trixie-nextfrom
kevinwieland:fix/legacy-os-trixie-fallback
Open

kevinwieland wants to merge 3 commits into
openWB:trixie-nextfrom
kevinwieland:fix/legacy-os-trixie-fallback

Conversation

@kevinwieland

@kevinwieland kevinwieland commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Only Debian Bullseye and Bookworm trigger this fallback. Trixie and future nonempty codenames are not rejected by this specific guard; missing, empty or unreadable OS identity aborts safely.

  • Redirect a trixie-next request before checkout to the latest stable pre-2.5 Release tag (2.0–2.4, including -Patch.N; excluding Beta/RC tags).
  • Catch old installed updaters that have already checked out trixie-next at the very beginning of atreboot.sh, before virtualenv, package, service, network or boot-configuration migrations.
  • Check again in packages/main.py before application imports. Old installed service units use ExecStartPre=-... and ignore a failed recovery; the independent core-start guard covers those units without assuming a new service template has been installed.
  • On early failure, best-effort clear both update-status topics and publish a fixed error message. Notification subprocesses have bounded timeouts.
  • Keep one failure event ID per boot/code version in private local state under data/log; QoS1 retries reuse the event, acknowledged/dismissed events are not republished. Automatic startup recovery attempts receive a five-minute cooldown after failure. Direct update_self.sh requests are not delayed by that cooldown.
  • After successful compatible Release checkout, publish this warning and allow 30 seconds before continuing the existing reboot path:

openWB 2.5.x benötigt ein Systemupdate. Bitte zuerst das OS-Update durchführen. Neustart auf das aktuelle Release wird durchgeführt.

The compatible Release's startup script replaces the guarded script after checkout. The ordinary Release clears transient system messages during startup; this change does not promise that the pre-reboot warning remains visible after reboot.

No automatic OS migration, device/module eligibility restriction, configuration reset or backup restore is introduced. Failed fetch, missing compatible tags or failed checkout do not trigger a reboot. A blocked legacy service can still reach its existing systemd restart limit; the cooldown avoids repeating Git recovery work on each immediate restart.

Verification

  • 48 automated tests passed on Linux, including 11 private guard tests; shell syntax and Python 3.9 syntax checks passed.
  • Real Bullseye Raspberry Pi testing covered ignored ExecStartPre failures, empty/missing OS identity, missing helper, damaged guard state, cooldown/retry boundaries and MQTT outage/reconnection with stable event IDs.
  • Full legacy Release 2.3.0 → test Trixie checkout → automatic compatible Release 2.3.0 → normal reboot completed. The exact warning was captured live; the new boot began 40 seconds after its message timestamp. Fresh increasing backend cycles, active core services, unchanged configuration/identity and stable operation after reboot were confirmed.
  • Pre-existing corrupt lab Git refs were repaired separately to enable the successful-path test. Automatic Git-ref repair is not included in this change.
  • Bookworm and future-codename cases were exercised with fixtures, not on separate Bookworm hardware. No physical charging-safety or visual UI qualification is claimed.
  • The four published runtime files were read back from GitHub and matched the qualified source hashes exactly.

Documentation and test additions are intentionally excluded as requested by the contributor. Existing repository tests are unchanged; private test evidence remains outside the PR.

Compatibility note

Already installed old updaters cannot be retroactively prevented from performing their initial checkout. The startup guard catches them afterwards. Preventing that first checkout requires a separate backport into the regular release; the Trixie-only startup rejection must not be copied unconditionally into a compatible legacy Release.

Recover old updaters to a stable pre-2.5 release before startup migrations.
Publish a bounded MQTT warning before the release reboot. Add sandbox tests.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 4 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="runs/atreboot.sh" line_range="10" />
<code_context>
+requiresSystemUpdate
+guardStatus=$?
+case "$guardStatus" in
+	0) exec bash "$OPENWBBASEDIR/runs/update_self.sh" "trixie-next" ;;
+	1) ;;
+	*) echo "Cannot read OS identity; refusing startup changes." >&2; exit 1 ;;
</code_context>
<issue_to_address>
**Incompatible application starts after failed recovery**

When recovery or OS-identity checks fail, `openwb2.service` ignores the nonzero `ExecStartPre` status because of its `-` prefix and runs `ExecStart` anyway, starting the incompatible checkout instead of blocking startup.

Remove the `-` prefix from `ExecStartPre` so a failed recovery prevents `ExecStart` from running.

Also at `runs/atreboot.sh:12`, `runs/update_self.sh:79`.
</issue_to_address>

### Comment 2
<location path="runs/atreboot.sh" line_range="7-10" />
<code_context>
+# Old updaters may already have checked out trixie-next. Recover before any
+# virtualenv, package, service, network or boot-configuration migration runs.
+source "$OPENWBBASEDIR/runs/os_update_guard.sh" || exit 1
+requiresSystemUpdate
+guardStatus=$?
+case "$guardStatus" in
+	0) exec bash "$OPENWBBASEDIR/runs/update_self.sh" "trixie-next" ;;
+	1) ;;
+	*) echo "Cannot read OS identity; refusing startup changes." >&2; exit 1 ;;
</code_context>
<issue_to_address>
**Bullseye and Bookworm reboot indefinitely**

When the service starts on Bullseye or Bookworm, including after a compatible Release is checked out, `atreboot.sh` checks only the OS codename and always calls `update_self.sh trixie-next`; `update_self.sh` selects and applies a compatible Release and reboots, so the next boot repeats the same path instead of starting the application.

Check the current checkout before invoking recovery, and skip recovery once a compatible Release is installed.
</issue_to_address>

### Comment 3
<location path="runs/os_update_guard.sh" line_range="11" />
<code_context>
+	source /etc/os-release || return 2
+	case "$VERSION_CODENAME" in
+		bullseye|bookworm) return 0 ;;
+		*) return 1 ;;
+	esac
+}
</code_context>
<issue_to_address>
**Unclassifiable OS proceeds as safe**

When `/etc/os-release` is readable and sourceable but `VERSION_CODENAME` is missing or empty, `requiresSystemUpdate` returns 1 for an empty `VERSION_CODENAME`, the same status used for a recognized non-target OS, so `atreboot.sh` continues startup migrations on an unclassifiable system still running `trixie-next`.

Return an error status for a missing or empty `VERSION_CODENAME` instead of treating it as a recognized non-target OS.
</issue_to_address>

### Comment 4
<location path="runs/atreboot.sh" line_range="12" />
<code_context>
+case "$guardStatus" in
+	0) exec bash "$OPENWBBASEDIR/runs/update_self.sh" "trixie-next" ;;
+	1) ;;
+	*) echo "Cannot read OS identity; refusing startup changes." >&2; exit 1 ;;
+esac
+
</code_context>
<issue_to_address>
**Failed guard leaves update status set**

When a user-triggered update runs while `/etc/os-release` is unreadable or lacks a usable identity, `System.perform_update` publishes `update_in_progress=true` before invoking `atreboot.sh`; on this error path the script exits before its normal status reset. The update indicator therefore remains set after OS identity cannot be read.

Reset `openWB/system/update_in_progress` on this early-exit path, or install cleanup that covers the guard check.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread runs/atreboot.sh Resolved
Comment thread runs/atreboot.sh Resolved
Comment thread runs/os_update_guard.sh Resolved
Comment thread runs/atreboot.sh Resolved
Block application imports despite ignored ExecStartPre failures. Handle empty
OS identities, clear early update flags, deduplicate bounded MQTT errors and
throttle automatic recovery retries. Allow 30 seconds for the reboot notice.

Runtime files match laboratory candidate 906d7be5e8cdb6d57468a669233eb09185d81199.
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