feat(agents): self-updating agent image variant
ci / test (pull_request) Successful in 9m12s
ci / lint (pull_request) Successful in 12m17s
ci / build (pull_request) Successful in 16m25s
ci / image (pull_request) Successful in 4m40s

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
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-23 18:57:48 +01:00
1 parent 431048e244
commit a35dadd8f6
20 files changed
+1577 -443

No files matched your search

+86
View File
@@ -0,0 +1,86 @@
package launcher
import (
"context"
"fmt"
"os"
"os/exec"
"runtime"
"runtime/debug"
"strings"
"syscall"
"time"
v1 "github.com/google/go-containerregistry/pkg/v1"
)
type process struct {
cmd *exec.Cmd
done chan struct{}
err error
}
// StartProcess runs path with the launcher's environment and output.
func StartProcess(path string) (Process, error) {
cmd := exec.Command(path)
cmd.Stdout, cmd.Stderr, cmd.Env = os.Stdout, os.Stderr, os.Environ()
if err := cmd.Start(); err != nil {
return nil, err
}
p := &process{cmd: cmd, done: make(chan struct{})}
go func() {
p.err = cmd.Wait()
close(p.done)
}()
return p, nil
}
// Done is closed when the agent has exited.
func (p *process) Done() <-chan struct{} { return p.done }
// Err is the agent's exit error.
func (p *process) Err() error { return p.err }
// Stop sends SIGTERM and kills the agent after timeout.
func (p *process) Stop(timeout time.Duration) {
_ = p.cmd.Process.Signal(syscall.SIGTERM)
select {
case <-p.done:
case <-time.After(timeout):
_ = p.cmd.Process.Kill()
<-p.done
}
}
// BinaryVersion asks an agent binary which release it is.
func BinaryVersion(path string) (string, error) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
out, err := exec.CommandContext(ctx, path, "version").Output()
if err != nil {
return "", err
}
v := strings.TrimSpace(string(out))
if v == "" || strings.ContainsAny(v, " \n") {
return "", fmt.Errorf("launcher: %s reports no release", path)
}
return v, nil
}
// Platform is the platform this launcher was built for, and so the agent
// binaries it runs.
func Platform() v1.Platform {
p := v1.Platform{OS: runtime.GOOS, Architecture: runtime.GOARCH}
if runtime.GOARCH != "arm" {
return p
}
p.Variant = "v7" // Go's default for linux/arm
if info, ok := debug.ReadBuildInfo(); ok {
for _, s := range info.Settings {
if s.Key == "GOARM" && s.Value != "" {
p.Variant = "v" + s.Value[:1]
}
}
}
return p
}