Skip to content

[M1.4c3] Container health checks and one-shot release tasks - #153

Merged
samuelmbabhazi merged 4 commits into
mainfrom
feat/m1.4c3-health-release
Nov 5, 2026
Merged

samuelmbabhazi merged 4 commits into
mainfrom
feat/m1.4c3-health-release

Conversation

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator

Closes #136 (with #151, #152).

What changed

M1.4c3: health checks and release tasks. Every container action of M1.4 now has a handler.

  • Docker client:
    • inspect now returns network addresses and exposed ports;
    • WaitContainer uses a second HTTP client without the 30 s response-header timeout, because the daemon answers only when the container exits.
  • health_check. The agent probes a managed container itself:
    • Target: only its private network address, never loopback, link-local (cloud metadata) or public addresses. The port is the requested TCP port, or for HTTP the single exposed TCP port; it is refused when ambiguous.
    • HTTP: a GET that never follows redirects, reads at most 4 KiB and treats 2xx/3xx as healthy. The path must be absolute, not network-path (//…), printable and at most 2048 bytes.
    • Timing: bounded intervals, timeouts, start period, thresholds and deadline.
    • Result: HealthCheckResult{healthy, consecutive_successes}; an unhealthy container fails the action.
  • run_release_task:
    • The spec is validated like CreateContainer, with the restart policy forced to no.
    • Step 1 creates the container, reusing it by fingerprint and refusing unmanaged ones.
    • Step 2 is non-retryable: start, wait within the timeout (1 s–1 h), then remove, so the exit code is the final outcome. On timeout the task is killed and removed. After a crash it is compensated (removed), never run again.
    • Result: ReleaseTaskResult{exit_code}.
  • Docs. The SPEC describes both actions. In the PLAN all M1.4 handlers are done, but M1.4 stays open until the integration tests against a real Docker daemon run (CI-1).

How it was tested

  • Health check:
    • reaches its threshold after a failure, on the exposed port of the private address;
    • an unhealthy container fails;
    • metadata (169.254.169.254), loopback, public and empty addresses are never probed;
    • ambiguous ports are refused;
    • 11 malicious specs are rejected (relative path, //evil network path, space, CRLF injection, oversize, port 0 or overflow, a tiny interval, a timeout longer than the interval, a threshold storm), as is a one-hour deadline.
  • Release task:
    • exit code 3 is reported, the task runs once with restart no and is removed;
    • a hanging task is killed and removed;
    • an unmanaged container is never run;
    • a two-hour timeout is refused.
  • go test -race ./agent/..., golangci-lint (0 issues) and the local gate pass.
  • Not run locally: a real Docker daemon. It runs in CI-1.

Security considerations

  • Probes cannot be aimed at host, metadata or external addresses.
  • Migrations never run twice after a crash.

@samuelmbabhazi
samuelmbabhazi merged commit dc87474 into main Nov 5, 2026
@samuelmbabhazi
samuelmbabhazi deleted the feat/m1.4c3-health-release branch November 5, 2026 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[M1.4c] Container lifecycle actions and validator fuzzing

1 participant