fix(update): probe the dashboard's real address after a self-update

The watchdog polled http://127.0.0.1:8420/healthz. Nothing binds 8420: the
daemon serves /healthz on [web].listen (127.0.0.1:8484 by default), so every
dashboard- or Telegram-initiated update waited out the 60s health timeout and
rolled back a release that had come up fine.

The daemon is the only process that knows which address it binds, so it now
derives the probe URL from its own config and hands it to the installer;
CommandInstaller exports ARCHIE_HEALTH_URL and the install script forwards it
into the watchdog unit, whose remaining default matches the dashboard's.

The suite never dialled the URL: every watchdog test faked curl as an
immediate failure, so only the unhealthy branch existed. One test now runs
the real curl against a real listener, and another pins the script default.
This commit is contained in:
sam committed 2026-09-09 23:29:11 +10:00
1 parent 694aaeb7cd
commit 2fe708aa64
9 files changed
+212 -7

No files matched your search

+18
View File
@@ -60,6 +60,24 @@ func DashboardURL(listen, token string) string {
return url
}
// HealthURL renders the base URL of this process's /healthz endpoint for
// out-of-process tooling: the update watchdog polls it after restarting
// archied to decide whether the release it just installed came up.
//
// It is empty when the dashboard is disabled, because /healthz is served by
// the dashboard listener and there is no other surface to probe.
//
// The address must remain the one archied itself binds. The watchdog is
// verifying archied's own restart, so probing an address served by a
// different process would report health for something it never restarted.
func HealthURL(listen string) string {
listen = strings.TrimSpace(listen)
if listen == "" || listen == "off" {
return ""
}
return strings.TrimSuffix(DashboardURL(listen, ""), "/")
}
// LoadOrCreateToken returns the dashboard token, generating and persisting one
// on first use. The token is created rather than configured so a non-loopback
// bind cannot be brought up unprotected by omission: there is no setup step to
+21
View File
@@ -15,3 +15,24 @@ func TestDashboardURL(t *testing.T) {
}
}
}
// TestHealthURL pins what out-of-process tooling probes after restarting
// archied. A wrong address here reads as an unhealthy release and triggers a
// rollback of one that came up fine (archie-core-1r4g).
func TestHealthURL(t *testing.T) {
for _, tc := range []struct{ listen, want string }{
{"127.0.0.1:8484", "http://127.0.0.1:8484"},
{"localhost:8484", "http://localhost:8484"},
{"0.0.0.0:8484", "http://localhost:8484"},
{":8484", "http://localhost:8484"},
{"[::]:8484", "http://localhost:8484"},
{"100.64.1.2:9000", "http://100.64.1.2:9000"},
{" 127.0.0.1:8484 ", "http://127.0.0.1:8484"},
{"off", ""},
{"", ""},
} {
if got := HealthURL(tc.listen); got != tc.want {
t.Errorf("HealthURL(%q) = %q, want %q", tc.listen, got, tc.want)
}
}
}