A pending update report used to be relayed verbatim. It is entirely self-reported: scripts/archie-update-watchdog decides "passed" from `curl -sf $HEALTH_URL/healthz`, which only proves that *a* daemon is answering, then copies the version the installer *intended* (ARCHIE_UPDATE_INSTALLED_GATEWAY) into the report. If the new binary never made it into service, the previous daemon answers the probe just as happily, so the message read "Update complete: daemon 1.9.8 -> 1.9.0. Health check passed - archie-core is healthy on the new version" about a version that was not running. That shipped: /update reported success and the next task hit the exact bug the update was meant to fix (#468). Report.Verify now checks the claims against the versions components report for *themselves* -- archied's compiled-in gatewayVersion, which no installer can talk it out of -- and partitions every claimed component into Confirmed, Drift or Unverified. What changed in MEANING: - A passed health check used to mean "the new version is running". It now means only "something answered"; the version claim is a separate, separately-checked assertion. - "Update complete ... healthy on the new version" used to be the only success wording. There are now three outcomes, because collapsing them is how the false success happened: confirmed, unconfirmed ("I could not confirm which version is actually running"), and contradicted ("Update did NOT take effect"). - An unverifiable component is NOT a failing one. Absent, empty, "unknown" (the watchdog's own default) and "dev" (an unstamped build) all mean "we could not check", never "it is wrong" -- treating them as drift would turn healthy updates whose bookkeeping went missing into reported failures. Verification covers the daemon only, deliberately. archied's compiled-in runtimeVersion records what its own pipeline stamped, not what the agent container runs, so vouching for the agent would be the same kind of guess this change exists to remove. The agent is therefore Unverified on every successful update, and the success message names it as unchecked rather than letting the confirmed daemon silently vouch for it. Drift detail is attached per component: one component can sit on the version the update meant to replace while another is on some third version, and a single explanatory sentence would state a falsehood about one of them. Regression tests were confirmed to fail against the pre-fix code, reproducing the exact false-success string, and each new guard was mutation-tested. The drift-ordering test's component count is load-bearing and documented: Go rotates small maps rather than permuting them, so 8 components let an unsorted implementation pass ~12% of the time while 9 fails it outright. Refs #522, #468
49 lines
2.1 KiB
Go
49 lines
2.1 KiB
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/samcharles93/archie-core/internal/config"
|
|
"github.com/samcharles93/archie-core/internal/installtype"
|
|
"github.com/samcharles93/archie-core/internal/releaseupdate"
|
|
)
|
|
|
|
// TestMakeUpdateServiceWiresInstallType is the regression test for
|
|
// archie-core-522's fail-closed guarantee actually reaching production: a
|
|
// Service built without InstallType always refuses to install (see
|
|
// releaseupdate.ErrUnknownInstallType), so wiring it here is what makes
|
|
// /update work at all for a correctly-stamped build, not just a detail.
|
|
func TestMakeUpdateServiceWiresInstallType(t *testing.T) {
|
|
cfg := config.Config{}
|
|
cfg.Chat.Telegram.UpdateCheckCommand = []string{"archie-update-check"}
|
|
cfg.Chat.Telegram.UpdateInstallCommand = []string{"archie-update-install"}
|
|
|
|
service := makeUpdateService(telegramSetup{Cfg: config.NewHolder(cfg)})
|
|
|
|
if service == nil {
|
|
t.Fatal("makeUpdateService returned nil despite a configured check command")
|
|
}
|
|
if service.InstallType != installtype.Type() {
|
|
t.Errorf("Service.InstallType = %q, want installtype.Type() = %q", service.InstallType, installtype.Type())
|
|
}
|
|
}
|
|
|
|
// TestDaemonRunningVersionsVouchesOnlyForItself: the point of checking a
|
|
// pending update report against running versions is that the value checked
|
|
// against is ground truth. This process's own compiled-in version is; the
|
|
// agent's is not, because runtimeVersion records what archied's release
|
|
// pipeline stamped, not what the agent container is actually running.
|
|
// Including a guess here would recreate the false success the check exists
|
|
// to catch, so its absence is the assertion.
|
|
func TestDaemonRunningVersionsVouchesOnlyForItself(t *testing.T) {
|
|
running := daemonRunningVersions()
|
|
|
|
if got := running[releaseupdate.ComponentDaemon]; got != gatewayVersion {
|
|
t.Errorf("running[%q] = %q, want gatewayVersion = %q", releaseupdate.ComponentDaemon, got, gatewayVersion)
|
|
}
|
|
if _, ok := running[releaseupdate.ComponentAgent]; ok {
|
|
t.Errorf("running vouches for %q, which this process cannot verify: %#v",
|
|
releaseupdate.ComponentAgent, running)
|
|
}
|
|
}
|