feat(update): let every host binary report its version, and refuse skew

The updater is component-driven: it compares the daemon and agent versions and
acts only when they differ, so a host whose individual binaries disagree looks
healthy. Carina ran a hand-installed archie-messaging 1.35.0 against a 1.30.0
state store and crash-looped on an RPC the older store does not serve, while
the updater reported "no approved component changes; nothing to install".

The reason a comparison was impossible: three of the six host binaries carried
no version at all. archie-ui, archie-messaging and archie-playbooks did not link
internal/app/archied, so the release ldflags never reached them; the gateway and
state store linked the variable but exposed no flag. Only archied could say what
it was.

- internal/buildinfo carries Version, stamped by all three build sites: the
  zip, install.sh, and the updater itself.
- Every host binary answers -version ("<name> <version>"). archied's existing
  two-line output is unchanged, because something parses it.
- archie-update-install reads each installed binary before it can report
  "nothing to install" and refuses, naming every binary that disagrees with the
  daemon's version; after an install it verifies the same set against the
  release it just installed, so a binary the release did not rebuild is skew
  rather than success.
- TestDistZipShipsEveryHostCommand pins stamping across the three build sites
  and requires each cmd/ to report, so a seventh command cannot arrive unstamped.
This commit is contained in:
sam committed 2026-09-22 14:52:18 +10:00
1 parent 3902b7ecbc
commit 70ea9b2a44
10 files changed
+197 -7

No files matched your search

+20
View File
@@ -152,6 +152,26 @@ func TestDistZipShipsEveryHostCommand(t *testing.T) {
// The installer now REFUSES an update when a service unit is missing and
// tells the operator to create it from this runbook, so a service the
// runbook never shows is a dead end rather than a documentation gap.
// Stamping is its own list, and a third build site made it three: the zip,
// install.sh and the updater each build the host binaries. A binary that
// cannot say what it is cannot be compared (archie-core-k94o), so a seventh
// command added unstamped fails here rather than waiting to be noticed.
for name, source := range map[string]string{
"deploy.yml": workflow,
"install.sh": installSh,
"archie-update-install": installer,
} {
if !strings.Contains(source, "internal/buildinfo.Version=") {
t.Errorf("%s does not stamp internal/buildinfo.Version", name)
}
}
for _, command := range wantBinaries {
main := readDeploymentFile(t, filepath.Join("cmd", command, "main.go"))
if !strings.Contains(main, "buildinfo") {
t.Errorf("cmd/%s/main.go has no way to report its version", command)
}
}
// The installer writes the units, so the runbook no longer carries their
// contents; it must still name each unit, or an operator cannot find one to
// inspect or override.