feat(agents): self-updating agent image variant #134

Merged
Sebi merged 3 commits from feat/autoupdate into main 2026-11-23 18:27:47 +00:00
Owner

Builds on #132 (signing) and #133 (agent images) and contains their commits; merge those first, then this diff shrinks to the launcher.

Image variant uptimesebi-checker:<tag>-autoupdate / uptimesebi-statuspage:<tag>-autoupdate: the plain image plus one layer with /usr/local/bin/launcher as entrypoint (UPTIME_LAUNCHER_AGENT baked in). Chosen by image, not by an environment variable; the plain image has no update code.

API GET /agent/v1/update (agent token): {"version": "<API release>", "image": "<UPTIME_AGENT_IMAGE>-<kind>:<tag>"}; no image for unreleased builds (dev). The call does not register an instance or count as a sign of life. New setting UPTIME_AGENT_IMAGE (default git.zb-server.de/zb-server/uptimesebi) for mirrors.

Launcher (internal/launcher, cmd/launcher):

  • runs the agent as a child, forwards shutdown; checks every 15 min (±10 %, first check after 30 s);
  • downloads the agent binary for its own platform (GOARM read from build info) from the image, after verifying the index signature: minisign over uptimesebi-<agent>@<digest> with the release version as trusted comment, from sha256-<hex>.minisig next to the image — keys from internal/signing/release.pub. An old release cannot be passed off as a new one, a moved tag or a foreign key is rejected, blobs are read by digest;
  • checks the downloaded binary reports the expected release (<agent> version), keeps it on the data volume, swaps gracefully (SIGTERM, shutdown timeout + 10 s), waits up to 2 min for /readyz, otherwise rolls back and skips that release for 6 h; a remembered release that crashes right after a restart falls back to the bundled one;
  • keeps only the current and the previous download.

agentimage (moved from tools/image): Build (optional launcher layer), ChannelTags (the first tag is the exact version the API names), Publish, Sign, Fetch, ReadFile. CI builds tools/image once and pushes plain + autoupdate for both agents, signed when RELEASE_SIGNING_KEY is set. The kaniko job now needs: build and uses its version (commit date + sha), so the API's release and the agent tags match on edge too.

Verified end to end with Docker against the dev API on :8080 (temporarily rebuilt as v0.0.2-test2 with a local registry, then restored): an edge-autoupdate container on v0.0.1-test1 found v0.0.2, verified it with the real release key, switched (release switched), stayed healthy; after docker restart it started v0.0.2 straight from the volume. Unit tests cover update, restart, rollback, crash fallback, bad/unsigned/foreign-signed downloads, invalid release names (-race -count=10). ARM binaries not executed (no QEMU here).

Not done: reporting launcher failures to the API (logged only); the console's outdated badge comes with #131.

Closes #129
Closes #128

🤖 Generated with Claude Code

https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3

> Builds on #132 (signing) and #133 (agent images) and contains their commits; merge those first, then this diff shrinks to the launcher. **Image variant** `uptimesebi-checker:<tag>-autoupdate` / `uptimesebi-statuspage:<tag>-autoupdate`: the plain image plus one layer with `/usr/local/bin/launcher` as entrypoint (`UPTIME_LAUNCHER_AGENT` baked in). Chosen by image, not by an environment variable; the plain image has no update code. **API** `GET /agent/v1/update` (agent token): `{"version": "<API release>", "image": "<UPTIME_AGENT_IMAGE>-<kind>:<tag>"}`; no image for unreleased builds (`dev`). The call does not register an instance or count as a sign of life. New setting `UPTIME_AGENT_IMAGE` (default `git.zb-server.de/zb-server/uptimesebi`) for mirrors. **Launcher** (`internal/launcher`, `cmd/launcher`): - runs the agent as a child, forwards shutdown; checks every 15 min (±10 %, first check after 30 s); - downloads the agent binary for its own platform (GOARM read from build info) from the image, after verifying the index signature: minisign over `uptimesebi-<agent>@<digest>` with the release version as trusted comment, from `sha256-<hex>.minisig` next to the image — keys from `internal/signing/release.pub`. An old release cannot be passed off as a new one, a moved tag or a foreign key is rejected, blobs are read by digest; - checks the downloaded binary reports the expected release (`<agent> version`), keeps it on the data volume, swaps gracefully (SIGTERM, shutdown timeout + 10 s), waits up to 2 min for `/readyz`, otherwise rolls back and skips that release for 6 h; a remembered release that crashes right after a restart falls back to the bundled one; - keeps only the current and the previous download. **agentimage** (moved from tools/image): `Build` (optional launcher layer), `ChannelTags` (the first tag is the exact version the API names), `Publish`, `Sign`, `Fetch`, `ReadFile`. CI builds `tools/image` once and pushes plain + autoupdate for both agents, signed when `RELEASE_SIGNING_KEY` is set. The kaniko job now `needs: build` and uses its version (commit date + sha), so the API's release and the agent tags match on edge too. **Verified end to end** with Docker against the dev API on :8080 (temporarily rebuilt as `v0.0.2-test2` with a local registry, then restored): an `edge-autoupdate` container on `v0.0.1-test1` found v0.0.2, verified it with the real release key, switched (`release switched`), stayed `healthy`; after `docker restart` it started v0.0.2 straight from the volume. Unit tests cover update, restart, rollback, crash fallback, bad/unsigned/foreign-signed downloads, invalid release names (`-race -count=10`). ARM binaries not executed (no QEMU here). Not done: reporting launcher failures to the API (logged only); the console's outdated badge comes with #131. Closes #129 Closes #128 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
Sebi added 4 commits 2026-11-23 17:58:01 +00:00
feat(release): sign checksums and publish an SBOM
ci / image (pull_request) Successful in 4m1s
ci / build (pull_request) Successful in 8m59s
ci / lint (pull_request) Successful in 10m34s
ci / test (pull_request) Successful in 12m29s
b1ca8eb19f
Releases carry SHA256SUMS signed in the minisign format (prehashed
Ed25519, the release tag as trusted comment) and an SPDX SBOM of the Go
modules and the npm packages the frontend build bundles. internal/signing
signs and verifies; the release keys are committed in release.pub and
compiled in, so the self-updating agents can check their downloads.
Without the RELEASE_SIGNING_KEY secret a release is published unsigned
with a warning.

Closes #34

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
feat(agents): multi-arch checker and status page images on scratch
ci / image (pull_request) Successful in 7m15s
ci / test (pull_request) Successful in 9m5s
ci / lint (pull_request) Successful in 14m17s
ci / build (pull_request) Successful in 15m59s
a9f94fc492
uptimesebi-checker and uptimesebi-statuspage for linux/amd64, arm64,
arm/v7 and arm/v6, from a Raspberry Pi Zero to servers. tools/image
assembles them from the cross-compiled binaries without Docker or
emulation: one layer on an empty base with the binary, a data volume
owned by the unprivileged user and a HEALTHCHECK running the new
`checker health` / `statuspage health` commands. The binaries embed time
zone data and fallback CA roots, so no base image ever needs updating.
CI pushes them with the same channel tags as the main image; releases
carry tarballs for all four platforms.

Refs #128

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
# Conflicts:
#	README.md
feat(agents): self-updating agent image variant
ci / image (pull_request) Successful in 4m40s
ci / lint (pull_request) Successful in 12m17s
ci / test (pull_request) Successful in 9m12s
ci / build (pull_request) Successful in 16m25s
a35dadd8f6
The -autoupdate variant of the checker and status page images adds a
launcher layer. The launcher runs the agent as a child process and keeps
it on the platform's release: GET /agent/v1/update names the API's own
release and the agent image for it, the launcher downloads the binary
for its platform from the registry, accepts it only when the index is
signed with a release key for exactly that version, swaps the agent
gracefully and rolls back when the new release does not become ready or
crashes right after starting. Agents never get ahead of the API, and
installations on unreleased builds are not followed.

CI pushes both variants and signs each index with RELEASE_SIGNING_KEY
(minisign signature in a sha256-<digest>.minisig image next to it). The
image builder moves to internal/agentimage; the API image job takes the
build job's version so the API reports the release its agents are tagged
with. Agents gain a version command.

Closes #129
Closes #128

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
Sebi merged commit 134e6e5436 into main 2026-11-23 18:27:47 +00:00
Sebi deleted branch feat/autoupdate 2026-11-23 18:27:50 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ZB-Server/uptimesebi#134