controller v0.68.1: boot-id recreate ALL deployed drive-backed apps (state-independent)

E1 caught it: filtering on State!=stopped missed apps docker hadn't auto-restarted
yet at the one-shot instant (5 apps exited after host reboot). Now recreates every
deployed present drive-backed app regardless of state (deployed=should run).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-15 19:42:21 +02:00
parent 42f69dadda
commit 7a85732fc1
3 changed files with 32 additions and 33 deletions
+12 -16
View File
@@ -5,7 +5,6 @@ import (
"gitea.dooplex.hu/admin/felhom-controller/internal/agentapi"
"gitea.dooplex.hu/admin/felhom-controller/internal/settings"
"gitea.dooplex.hu/admin/felhom-controller/internal/stacks"
)
func TestAgentWhere(t *testing.T) {
@@ -21,32 +20,29 @@ func TestAgentWhere(t *testing.T) {
}
}
// TestShouldRecreateOnBoot pins the deterministic boot-id recreate decision.
// TestShouldRecreateOnBoot pins the DETERMINISTIC boot-id recreate decision: recreate EVERY deployed
// drive-backed present app, independent of its current container state.
//
// COMPANION GUARD: the OLD timed-sample (`stackStartedRecently || State∈{exited,restarting,unhealthy}`)
// MISSED a healthy-but-stale Running app sampled minutes after boot — the first case below would be
// `false` under it. The boot-id path recreates it (it came back on this boot, drive present). It still
// respects a cleanly user-Stopped app and never touches absent-drive / SSD / not-deployed apps.
// COMPANION GUARD: the pre-fix logic (the old `stackStartedRecently`, and even a `State!=stopped` filter)
// MISSED an app that was Stopped/Exited at the one-shot instant — docker hadn't auto-restarted it yet
// after the boot. The "exited" and "stopped" cases below are `true` here: a state-filtered impl returns
// false for them and the app stays down (exactly what happened live: 5 apps exited after a host reboot).
func TestShouldRecreateOnBoot(t *testing.T) {
present := map[string]bool{"/mnt/felhom-drives/felhom-flash": true}
cases := []struct {
name string
deployed bool
hdd string
state stacks.ContainerState
want bool
}{
{"healthy-but-stale (old sample MISSED this)", true, "/mnt/felhom-drives/felhom-flash", stacks.StateRunning, true},
{"exited", true, "/mnt/felhom-drives/felhom-flash", stacks.StateExited, true},
{"unhealthy", true, "/mnt/felhom-drives/felhom-flash", stacks.StateUnhealthy, true},
{"user-stopped (respected)", true, "/mnt/felhom-drives/felhom-flash", stacks.StateStopped, false},
{"not-deployed", true, "/mnt/felhom-drives/felhom-flash", stacks.StateNotDeployed, false},
{"drive absent (gate handles)", true, "/mnt/felhom-drives/felhom-usb", stacks.StateRunning, false},
{"SSD path never", true, "/mnt/sys_drive/felhom-data", stacks.StateRunning, false},
{"app.yaml not deployed", false, "/mnt/felhom-drives/felhom-flash", stacks.StateRunning, false},
{"deployed+present (recreate regardless of state)", true, "/mnt/felhom-drives/felhom-flash", true},
{"drive absent (gate handles)", true, "/mnt/felhom-drives/felhom-usb", false},
{"SSD path never", true, "/mnt/sys_drive/felhom-data", false},
{"app.yaml not deployed", false, "/mnt/felhom-drives/felhom-flash", false},
{"no HDD_PATH (SSD-resident)", true, "", false},
}
for _, c := range cases {
if got := shouldRecreateOnBoot(c.deployed, c.hdd, c.state, present); got != c.want {
if got := shouldRecreateOnBoot(c.deployed, c.hdd, present); got != c.want {
t.Errorf("%s: shouldRecreateOnBoot = %v, want %v", c.name, got, c.want)
}
}