feat: self-update of master and agents (#15) #32

Merged
shcizo merged 3 commits from feat/self-update-15 into main 2026-10-13 10:17:55 +00:00
Owner

Summary

  • The master's Compose service and each agent's own Compose service can be updated like any other service (button, version picker, auto, webhook, poller). An agent's own Swarm service is still refused.
  • An agent updating itself runs docker compose up -d in a short-lived helper container (its own image, its own mounts, labels se.shcizo.package-updater.self-update.*). The new agent finds the helper at startup, resumes the job before its hello, and reports the real exit code and the pinned ref as a normal job.result. No hub, store or schema changes for this.
  • Jobs for an agent's own service run last, in the agent's queue and in the order the poller and webhook start jobs. Protocol version 4; any service running the AGENT_IMAGE repo is only routed to v4 agents, so an older agent can never stop itself.

Closes #15

Test plan

  • go test ./...
  • go test -race ./internal/agent/... ./internal/master/... ./internal/e2e/
  • go test -tags integration ./internal/master/store/ against Postgres (not run; only the merge refusal reason changed in store)
  • Agent updates itself to a new digest: helper visible during the update, new agent container, job succeeded with repo:tag@digest, helper removed afterwards
  • Agent update with no new digest: the old agent reports, helper removed
  • Master updates itself: job succeeded once the master is back
  • Master and agent in auto, one push: master job first, agent job last, no job lost
  • Failed recreate: the old agent reports failed with the compose output and keeps running
  • Overview: badge "This agent" and a normal auto toggle on the agent's own row
## Summary - The master's Compose service and each agent's own Compose service can be updated like any other service (button, version picker, auto, webhook, poller). An agent's own Swarm service is still refused. - An agent updating itself runs `docker compose up -d` in a short-lived helper container (its own image, its own mounts, labels `se.shcizo.package-updater.self-update.*`). The new agent finds the helper at startup, resumes the job before its hello, and reports the real exit code and the pinned ref as a normal `job.result`. No hub, store or schema changes for this. - Jobs for an agent's own service run last, in the agent's queue and in the order the poller and webhook start jobs. Protocol version 4; any service running the `AGENT_IMAGE` repo is only routed to v4 agents, so an older agent can never stop itself. Closes #15 ## Test plan - [x] `go test ./...` - [x] `go test -race ./internal/agent/... ./internal/master/... ./internal/e2e/` - [ ] `go test -tags integration ./internal/master/store/` against Postgres (not run; only the merge refusal reason changed in store) - [ ] Agent updates itself to a new digest: helper visible during the update, new agent container, job succeeded with `repo:tag@digest`, helper removed afterwards - [ ] Agent update with no new digest: the old agent reports, helper removed - [ ] Master updates itself: job succeeded once the master is back - [ ] Master and agent in auto, one push: master job first, agent job last, no job lost - [ ] Failed recreate: the old agent reports failed with the compose output and keeps running - [ ] Overview: badge "This agent" and a normal auto toggle on the agent's own row
shcizo added 3 commits 2026-10-13 10:14:51 +00:00
shcizo merged commit 850a670446 into main 2026-10-13 10:17:55 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: shcizo/package-updater#32