Repository navigation
feat(fleet): per-cell disk limits, egress policy, backup/restore, and cell diagnostics - #104828
Conversation
…s, 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)
- 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
…estore 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
…alidate 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
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fd4dd72245
ℹ️ 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".
| } else if (inspection.storageOpt.size !== undefined) { | ||
| findings.push( | ||
| finding( | ||
| "disk-limit", | ||
| "pass", | ||
| `Container writable-layer disk limit is ${inspection.storageOpt.size}.`, |
There was a problem hiding this comment.
Fail doctor when disk quota label is missing
When a Docker cell has an applied StorageOpt.size but the fleet openclaw.fleet.disk-limit label is missing, this branch reports the disk-limit check as pass. Upgrade and restore replay the quota only from that label in buildProfileBaseFromInspection, so an out-of-band recreated/drifted container with the storage option but no label will be marked healthy by fleet doctor and then silently lose its writable-layer cap on the next upgrade or restore. Treat the applied-without-label case as drift instead of passing it.
Useful? React with 👍 / 👎.
|
Codex review: needs real behavior proof before merge. Reviewed July 11, 2026, 8:56 PM ET / July 12, 2026, 00:56 UTC. Summary PR surface: Source +1747, Tests +1164, Docs +59. Total +2970 across 20 files. Reproducibility: yes. A Docker inspection with Review metrics: 1 noteworthy metric.
Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Copy recommended automerge instructionNext step before merge
Security Review findings
Review detailsBest possible solution: Make the disk-limit diagnostic fail whenever an applied Docker quota lacks the fleet replay label, add the inverse-drift regression test, and land only after the repaired invariant passes focused and exact-head fleet validation. Do we have a high-confidence way to reproduce the issue? Yes. A Docker inspection with Is this the best way to solve the issue? No as currently implemented. The overall label-backed replay design is coherent, but doctor must enforce that same invariant instead of treating a non-replayable quota as healthy. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against ecefc6cab69e. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +1747, Tests +1164, Docs +59. Total +2970 across 20 files. View PR surface stats
Security concerns:
Acceptance criteria:
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
Merged via squash.
|
… 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
Related: #104436 (v1 shipped in #104527; this implements the deferred v1.1 operational-hardening items)
What Problem This Solves
The fleet cell supervisor shipped in #104527 left four operational gaps for hosts running multiple tenant cells:
fleet logs(added in feat(fleet): stream tenant cell logs through the supervisor #104669) streamed raw output with no token redaction, and there was no way to detect out-of-band container drift (edited hardening flags, wrong port binding, foreign ownership, wrong directory modes).Why This Change Was Made
These are the explicitly deferred v1.1 items from the merged threat-model review. Every new verb follows the v1 conventions: argv-only container commands with validated tokens, label-anchored ownership assertions before every action, per-tenant
state_leasesfor mutations, secrets kept out of argv/SQLite, fail-closed behavior, and no schema or config-surface additions (disk state replays from a fleet-owned container label; egress mode lives on the network object itself).Three design points were settled by live backend proof rather than assumption:
--network internalis Podman-only. Live testing on Docker 28.0.4 shows published loopback ports do not work on--internalnetworks (docker psshows no ports; connections refused), so a Docker internal cell would have an unreachable Gateway and permanently failing health gates. Fleet fails such a create closed with an actionable error (Podman orDOCKER-USERhost firewall). On Podman 4.9.3 the published loopback port keeps working while egress is blocked (verified live, including from inside a running cell).--diskreplays via a fleet-owned label, notHostConfig.StorageOpt: Podman's inspect schema has noStorageOptfield at all (verified live:can't evaluate field StorageOpt in type *define.InspectContainerHostConfig), so inspect-based replay would silently drop a Podman cell's quota on upgrade/restore.--cap-drop=ALLinto individual caps but reports an empty top-levelEffectiveCaps(verified live), and Podman'snetwork inspectomits the containers map entirely, so attachment drift is only failed on affirmative evidence.User Impact
openclaw fleet creategains--disk <size>(opt-in writable-layer quota via--storage-opt, carried acrossupgrade/restore; unsupported storage backends fail create with a support-matrix hint — verified live on overlay2/extfs for both runtimes) and--network bridge|internal(defaultbridge, no behavior change).openclaw fleet backup <tenant> [--out] [--max-bytes]/openclaw fleet restore <tenant> --from <path> [--force] [--max-bytes]: 0600 single-file archives with manifest tenant binding, mandatory data+auth trees, symlink/hardlink/backslash rejection, byte and path-segment budgets, root-bounded extraction, atomic no-overwrite publish, lease fencing (including probes during long streams), Gateway-token rotation on restore, phase-accurate failure recovery notes, and restart of a force-stopped cell when restore aborts before removal.openclaw fleet logskeeps the feat(fleet): stream tenant cell logs through the supervisor #104669 streaming surface (--follow,--tail,--since) and now pipes output through a boundary-safe, backpressure-aware redaction filter so the cell's Gateway token never reaches the terminal.openclaw fleet doctor [tenant] [--json]: read-only per-cell audit (ownership labels, health, cap-drop/no-new-privileges/init/restart-policy/resource drift, loopback port binding vs registry, token presence, disk-limit label consistency, network ownership/attachments/egress mode, 0700 state-dir permissions); any failed finding exits nonzero.openclaw.jsonkeys; no state-schema changes.Evidence
All remote proof ran on Blacksmith Testbox through Crabbox (trusted maintainer code), Docker 28.0.4 (overlay2/extfs) + Podman 4.9.3:
pnpm test src/fleet src/cli/fleet-cli— 209 passed locally on the final head; both Vitest shards green remotely (tbx_01kx9sz2hspew5h436anqx5b98).pnpm check:changed— green end-to-end ontbx_01kx9sz2hspew5h436anqx5b98(exit 0 with pipefail);pnpm build—INEFFECTIVE_DYNAMIC_IMPORTcount 0;tsgocore + core-test lanes 0 errors on the final head.ghcr.io/openclaw/openclaw:latestcells):--diskrejection with actionable backend error + registry rollback; Docker--network internalfail-closed rejection; Podman internal cell with healthz 200 over the published loopback port while in-cell egress is blocked;fleet logswith token verified absent in both bounded and--followoutput against a live gateway;fleet doctorclean on Docker and Podman cells, then failing on induceddocker update --restart nodrift with exit 1; backup (0600, manifest+data+auth) → tamper marker → restore → state replaced, token rotated, old token absent from container env, healthz 200 after restart; restore refusal on a running cell without--force(runs ontbx_01kx9a196ecjkr87yqjw4nsk9s,tbx_01kx9j2sv944f0ej0k2tffrn09,tbx_01kx9sz2hspew5h436anqx5b98).--storage-optrejection messages on both runtimes, Podman missingHostConfig.StorageOpt, PodmanCapDropexpansion +EffectiveCapssemantics, Podman missing network containers map.$autoreview(Codexgpt-5.6-sol, xhigh, fast tier): iterated across many rounds until only rejected findings remained; ~25 accepted findings fixed (including an auth-tree data-loss bug, atomic archive publish, entry/byte budget symmetry, streamed-redaction boundary safety, backpressure, root-restore ownership, Podman cap-drop/attachment/doctor semantics). Rejected with cited evidence: in-walk lease checkpoints (interval heartbeat owns lease liveness, matching the v1 upgrade profile), upgrade-validation-ordering claim (profiles validate before any destructive step), persisted network-mode intent (new contract; observed egress mode is reported instead — follow-up candidate), and a millisecond inspect-to-attach logs race that sits inside the trusted-operator model.Known limitation stated in docs:
--diskcaps the container writable layer only; the bind-mounted per-tenant state dir is host storage and needs host filesystem project quotas.