Repository navigation
[M1.4c2] Container start, stop and confirmed removal - #152
Merged
Merged
Conversation
Signed-off-by: Samuel Mbabhazi <[email protected]>
Signed-off-by: Samuel Mbabhazi <[email protected]>
samuelmbabhazi
added a commit
that referenced
this pull request
Nov 5, 2026
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. --------- Signed-off-by: Samuel Mbabhazi <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #136.
What changed
M1.4c2: container lifecycle handlers.
start_container,stop_containerandremove_containeraccept a full 64-hex Docker id or ansk-name, never an id prefix. They act only on containers carryingsk.managed=true.remove_volumes=truedestroys data. It needs acontainer.removeconfirmation for that exact container, spent in a non-retryable first step. A token sent withoutremove_volumesis refused as malformed input.How it was tested
v=true.host, and a suffixed id. A one-hour stop timeout is also rejected.go test -race ./agent/...,golangci-lint(0 issues) and the local gate pass.Security considerations