Repository navigation
feat(agent): ship container logs to the control plane (part of #232) - #464
Merged
Merged
Conversation
#232) The maintainer chose a dedicated ShipLogs stream, as for metrics (ADR 0024): no published port, agent credential or agent label to trust. Acknowledged batches and a cursor per container let logs survive a control plane outage within Docker's rotation; the agent redacts secret environment values first. Signed-off-by: samuel mbabhazi <[email protected]>
Create, start with the daemon's hijacked connection, resize and inspect an exec. The multiplexed output is read frame by frame, refusing invalid headers and frames over 1 MiB. Tested against a fake daemon and a real Docker. Signed-off-by: samuel mbabhazi <[email protected]>
The agent validates the session (managed container, bounded argv, user, time limit), opens an ExecStream on the current gateway session, and relays stdin, resizes and close to Docker, output and the exit code back. A session never resumes after a restart. Signed-off-by: samuel mbabhazi <[email protected]>
ADR 0029: LogsOpen with the lease epoch, LogBatch of entries (container, stream, Docker time, line, truncated) acknowledged by sequence number, and Welcome.logs. ConfigUpdate.logs_endpoint is deprecated. Signed-off-by: samuel mbabhazi <[email protected]>
Follows Docker's logs API with timestamps from a time on, joins the lines Docker split, cuts them at 16 KiB, replaces invalid UTF-8 and drops frames without a timestamp. Refuses a container with a terminal. Tested against a fake daemon and a real Docker. Signed-off-by: samuel mbabhazi <[email protected]>
…ag, and end with their context From review: Docker's default detach sequence is replaced by one a terminal user does not type; CreateExec returns the instance with its terminal flag, which StartExec repeats; the start's context bounds the session; Next returns at most max bytes in both modes and refuses no room; errors keep their cause. Signed-off-by: samuel mbabhazi <[email protected]>
Signed-off-by: samuel mbabhazi <[email protected]>
From review: the action now ends once the session started, and the session runs under an owner the gateway closes, outside the journal's one step at a time. A stalled stream no longer outlives the time limit, the owner's close is told as closed, and stdin in flight after its close is dropped instead of killing the session. Signed-off-by: samuel mbabhazi <[email protected]>
Signed-off-by: samuel mbabhazi <[email protected]> # Conflicts: # agent/internal/actions/docker.go # agent/internal/agent/gateway.go
…gin/feat/232-ship-logs-proto' into feat/232-log-shipper
Signed-off-by: samuel mbabhazi <[email protected]>
…nowledged batches (part of #232) ADR 0029: on a ShipLogs stream opened after Welcome, the agent follows each running managed container from its cursor, redacts its secret variables (named by a new sk.secret_env label), sends batches of at most 256 entries and 60 KiB with four in flight, and moves each container's cursor only once the control plane acknowledged its batch. A failed stream is opened again. Signed-off-by: samuel mbabhazi <[email protected]>
Docker orders stdout and stderr by timestamp, and two writes in the same instant can come out either way, as CI showed. Signed-off-by: samuel mbabhazi <[email protected]>
…nce full Signed-off-by: samuel mbabhazi <[email protected]>
Signed-off-by: samuel mbabhazi <[email protected]>
…232-log-shipper Signed-off-by: samuel mbabhazi <[email protected]> # Conflicts: # agent/internal/actions/exec.go # agent/internal/actions/exec_test.go # agent/internal/agent/gateway.go # agent/internal/gateway/streams.go
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 46 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
…frames Signed-off-by: samuel mbabhazi <[email protected]>
…gement moves Signed-off-by: samuel mbabhazi <[email protected]>
This was referenced Nov 25, 2026
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 #232 (M6.1). The agent side of ADR 0029: it follows every managed container's output and sends it to the control plane on the
ShipLogsstream, which #461 writes to VictoriaLogs.Stacked on #459 (the Docker logs reader). Retarget to
mainonce #459 is merged.What changed
agent/internal/logship: the shipper.sk.managed, from that container's cursor, and rescans every 10 s for new ones. A follower that ends is started again on the next scan, including when the daemon restarts with live-restore.LogLine.Resume.Resumeis the time from which reading again loses nothing, even while a line of the other stream is still being joined (feat(agent): read a container's log lines from a cursor (part of #232) #459). Lines therefore arrive at least once, and none is lost while Docker still holds it.redact.go): the values of the container's secret environment variables of 8 bytes or more become[redacted]before a line leaves the agent, longest first. Their names come from the newsk.secret_envlabel, and their values from the container's own environment. A redacted line is cut again to 16 KiB.actions:CreateContainersetssk.secret_env, the sorted names of the spec's secrets. Names are not secret.journal: alog_cursorstable, keyed by container name. A cursor only moves forward, and those of containers that are gone are forgotten.gateway:Streams.OpenLogsopens the stream. The runner starts the shipper with the session's lease epoch once Welcome says logs are kept, and stops it with the session. A failed stream is retried after 5 s../agent/internal/logship/.How it was tested
TestRealShipperSendsAContainersRedactedLinesAndKeepsItsCursorruns against a real Docker Engine: a busybox container prints a secret on stderr, which arrives astoken is [redacted], and the cursor is stored. It now checks only its own container, so it also passes on an engine that runs other managed containers (it did, in the lab node).0.1.0-lab.27from this branch on a node with an nginx application:go test ./agent/...and golangci-lint pass.Security considerations