Repository navigation
feat(fleet): stream tenant cell logs through the supervisor - #104669
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d63172f8ea
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (!Number.isSafeInteger(options.tail) || options.tail < 1) { | ||
| throw new Error("Fleet logs --tail must be a positive integer."); |
There was a problem hiding this comment.
Allow --tail 0 for log streaming
When users want to follow only new output (openclaw fleet logs acme --follow --tail 0), this validation rejects the standard container-log value before invoking Docker/Podman. Docker documents --tail as the number of lines and only calls negative or non-integer values invalid (https://docs.docker.com/reference/cli/docker/container/logs/), and Podman says --tail=LINES must be an integer with -1 meaning all logs (https://docs.podman.io/en/v5.0.1/markdown/podman-logs.1.html), so 0 should be allowed here and in the Commander parser rather than treated as an error.
Useful? React with 👍 / 👎.
| if (options.follow && (deliberateStop || result.code === 130)) { | ||
| return; |
There was a problem hiding this comment.
Treat SIGPIPE as a clean log pipe close
For non-following log reads used in scripts, e.g. openclaw fleet logs acme --tail 10000 | head, the inherited stdout can make the Docker/Podman child terminate with SIGPIPE once the downstream reader exits. The code comment classifies a closed downstream pipe as deliberate, but this branch only suppresses deliberate stops when options.follow is set, so the documented pipeline use can produce a spurious logs failed with signal SIGPIPE error for bounded reads.
Useful? React with 👍 / 👎.
|
Merged via squash.
|
… cell diagnostics (#104828) * feat(fleet): per-cell disk limits, egress policy, backup/restore, logs, and doctor - fleet create --disk <size> caps the container writable layer via --storage-opt; unsupported storage backends fail create with an actionable support-matrix error, and the limit replays across upgrade/restore through a fleet-owned container label because Podman inspect has no HostConfig.StorageOpt. - fleet create --network bridge|internal adds an opt-in no-egress mode on Podman (published loopback port keeps working, verified live); Docker internal cells are rejected fail-closed because Docker does not publish loopback ports on internal networks. - fleet backup/restore: per-tenant 0600 tar archives with manifest tenant binding, symlink/hardlink rejection, byte and path-segment budgets, root-bounded extraction, atomic no-overwrite publish, lease fencing, and Gateway token rotation on restore; failures preserve displaced data and never leave a force-stopped or half-started cell serving silently. - fleet logs: ownership-asserted, bounded, token-redacted on both streams, with a generation re-check so a concurrent restore cannot leak a rotated token. - fleet doctor: read-only per-cell audit of ownership labels, health, hardening drift, loopback port binding, token presence, network egress mode, and 0700 state-dir permissions; any failed finding exits nonzero. Cross-runtime checks are grounded in live-verified Docker 28/Podman 4.9 inspect shapes (CapDrop vs EffectiveCaps, missing StorageOpt, missing network containers map). Related: #104436 (v1 shipped in #104527) * fix(fleet): harden streamed log redaction and root restore ownership - redacting stream writer honors target backpressure, retains secret-prefix overlap across forced long-line flushes, and never splits a token between emitted chunks - root-invoked restores repair ownership for explicit non-root user mappings instead of leaving root-owned 0700 state trees - fleet logs merges the shipped --follow streaming surface (#104669) with the v1.1 token-redaction contract * fix(fleet): stream partial log lines live and report phase-accurate restore recovery paths - the redacting log writer emits safe text on every chunk (retaining only a possible token prefix) so unterminated progress output streams immediately - restore failure notes distinguish pre-swap, displaced, and swapped states so operators recover the correct tree, and an unavailable runtime inspection is reported as an unverified replacement instead of silence * fix(fleet): reject backslash archive paths, guard stderr pipes, and validate disk-limit labels in doctor - restore/backup path rules reject literal backslashes so a tampered entry cannot validate as one path and extract as another on POSIX - fleet logs handles broken pipes on stderr as well as stdout - fleet doctor fails malformed disk-limit labels that would break upgrade/restore replay instead of reporting them as passing
… cell diagnostics (openclaw#104828) * feat(fleet): per-cell disk limits, egress policy, backup/restore, logs, and doctor - fleet create --disk <size> caps the container writable layer via --storage-opt; unsupported storage backends fail create with an actionable support-matrix error, and the limit replays across upgrade/restore through a fleet-owned container label because Podman inspect has no HostConfig.StorageOpt. - fleet create --network bridge|internal adds an opt-in no-egress mode on Podman (published loopback port keeps working, verified live); Docker internal cells are rejected fail-closed because Docker does not publish loopback ports on internal networks. - fleet backup/restore: per-tenant 0600 tar archives with manifest tenant binding, symlink/hardlink rejection, byte and path-segment budgets, root-bounded extraction, atomic no-overwrite publish, lease fencing, and Gateway token rotation on restore; failures preserve displaced data and never leave a force-stopped or half-started cell serving silently. - fleet logs: ownership-asserted, bounded, token-redacted on both streams, with a generation re-check so a concurrent restore cannot leak a rotated token. - fleet doctor: read-only per-cell audit of ownership labels, health, hardening drift, loopback port binding, token presence, network egress mode, and 0700 state-dir permissions; any failed finding exits nonzero. Cross-runtime checks are grounded in live-verified Docker 28/Podman 4.9 inspect shapes (CapDrop vs EffectiveCaps, missing StorageOpt, missing network containers map). Related: openclaw#104436 (v1 shipped in openclaw#104527) * fix(fleet): harden streamed log redaction and root restore ownership - redacting stream writer honors target backpressure, retains secret-prefix overlap across forced long-line flushes, and never splits a token between emitted chunks - root-invoked restores repair ownership for explicit non-root user mappings instead of leaving root-owned 0700 state trees - fleet logs merges the shipped --follow streaming surface (openclaw#104669) with the v1.1 token-redaction contract * fix(fleet): stream partial log lines live and report phase-accurate restore recovery paths - the redacting log writer emits safe text on every chunk (retaining only a possible token prefix) so unterminated progress output streams immediately - restore failure notes distinguish pre-swap, displaced, and swapped states so operators recover the correct tree, and an unavailable runtime inspection is reported as an unverified replacement instead of silence * fix(fleet): reject backslash archive paths, guard stderr pipes, and validate disk-limit labels in doctor - restore/backup path rules reject literal backslashes so a tampered entry cannot validate as one path and extract as another on POSIX - fleet logs handles broken pipes on stderr as well as stdout - fleet doctor fails malformed disk-limit labels that would break upgrade/restore replay instead of reporting them as passing
What Problem This Solves
Fleet (#104527) manages cell lifecycle but gives operators no way to see why a cell is unhealthy — the first diagnostic step after a failed
fleet statushealth probe is container logs, and today that means bypassing the supervisor and its ownership checks with a hand-crafteddocker logs openclaw-cell-<tenant>. Closes #104644.Why This Change Was Made
Adds
openclaw fleet logs <tenant> [--follow] [--tail <n>] [--since <value>]:docker|podman logsvia spawn, no capture cap, no timeout) rather than the existing captured executor, which is sized for short commands (4 MiB / 10 min). The seam carries no env or token argv, so no redaction machinery applies; commented at the seam.--follow— a non-followlogsexiting 130 remains an error.--tailis a strict positive integer;--sincemust be non-empty, must not start with-, and must not contain whitespace/control characters (passed through verbatim otherwise, so both durations and timestamps work).--jsonmode by design: logs are a raw stream; documented alongside--tailguidance for scripting.Implementation was Codex-built from a frozen spec and reviewed line-by-line; one review finding (SIGINT forwarding) was fixed before this PR.
User Impact
Operators diagnose cells without leaving the supervisor's ownership guarantees. Fleet remains experimental; no config surface changes, no new dependencies, no changes to existing commands.
Evidence
pnpm tsgo,pnpm check:test-types, oxlint, scoped format: clean.attachChildProcessBridge(full termination-signal set, self-detaching) and an honest{code, signal}stream result. A further cycle narrowed follow-mode tolerance to deliberate-stop signals only (forwarded termination set + SIGPIPE + exit 130) so crash signals like SIGSEGV are never masked as operator stops, with regression coverage. Final review: clean, "no accepted/actionable findings" (0.93). One reviewer suggestion — editing CHANGELOG.md — was rejected per repo policy (changelog is release-only; release-note context lives in this PR body).CapDrop=["ALL"]; podman equivalently enumerates the dropped default capability set),/healthzok on first probe,fleet logs --tail 5streaming real gateway boot lines from inside both cells, upgrade with token hash carry-over,rm --purge-dataleaving zero containers/networks and purged data dirs.ALL_SCENARIOS_PASSED.