Repository navigation
feat(fleet): multi-tenant hosting via openclaw fleet cell supervisor - #104527
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c8112156ec
ℹ️ 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".
| "--network", | ||
| profile.networkName, | ||
| "-p", | ||
| `127.0.0.1:${profile.hostPort}:${FLEET_GATEWAY_PORT}`, |
There was a problem hiding this comment.
Add host gateway mapping for Docker cells
For Linux Docker Engine cells, the official Docker setup documents host.docker.internal as the URL tenants should use for host-side LM Studio/Ollama and says custom docker run users must add --add-host=host.docker.internal:host-gateway (docs/install/docker.md:305-319). The fleet profile only joins the per-cell bridge and publishes the gateway port here, so a tenant configuring those documented Docker provider URLs inside a fleet-created Docker cell cannot reach the host provider. Add the Docker-only host-gateway mapping when building the cell args; Podman can keep its own host-alias behavior.
Useful? React with 👍 / 👎.
|
Codex review: stale review; fresh review needed. Summary Next step Review history (4 earlier review cycles)
|
Pre-merge verificationAutomated validation
Live scenario proof (real user path; macOS host, OrbStack Docker 29.4.0, real
Known gaps
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6468ee1fd2
ℹ️ 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".
| hostIdentity: HostIdentity | undefined; | ||
| user?: string; | ||
| }): Promise<CellContainerProfile["containerUser"]> { | ||
| const match = params.user?.match(/^(\d+):(\d+)$/u); |
There was a problem hiding this comment.
Preserve inspected image users during upgrade
When a cell was created by root against rootful Docker, Fleet chowns the mounts to uid 1000 (src/fleet/service.runtime.ts:200-224) and the official image runs as USER node (Dockerfile:359-362). On a later fleet upgrade run by a non-root docker-group operator, Docker inspect reports Config.User as node, but this numeric-only match ignores that and falls through to the current host UID, so both the replacement and rollback containers are recreated with --user <operator uid>:<gid> and cannot read the 0700 mounts. Preserve a non-numeric inspected user, or map the official node user to 1000, instead of substituting the caller.
Useful? React with 👍 / 👎.
22ba8c9 to
2bcbad7
Compare
|
Merged via squash.
|
|
Follow-up live proof for the gap noted in the pre-merge verification (macOS-only live pass): the full fleet scenario now also passed on Linux against both supported runtimes, on a Blacksmith Testbox (Actions run https://github.com/openclaw/openclaw/actions/runs/29165538971,
This closes the "no Linux-host live pass; Podman covered by tests only" gaps from the earlier verification comment. |
… 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
…penclaw#104527) * feat(fleet): add openclaw fleet cell supervisor for multi-tenant hosting * test(fleet): cover cell profile, registry, containers, and service flows * docs(fleet): document multi-tenant hosting and the fleet CLI * fix(fleet): verify upgrade replacements and release foreign-collision reservations * fix(fleet): gate upgrade commit on replacement health * docs(fleet): mark fleet experimental and pin its single-host scope * test(fleet): make incomplete-profile casts explicit for test-type lane * fix(state): regenerate kysely schema artifacts after rebase conflict
… 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
OpenClaw's trust model is one trusted operator domain per gateway: all agents, plugins, and Codex app-servers share one Node process, one OS user, and one shared-secret gateway credential. Operators who want to host agents for multiple users have no supported deployment shape, and in-process separation cannot become one — tenant plugins and Codex installs are arbitrary code running with the whole gateway's authority. Closes #104436.
Why This Change Was Made
Treat the container boundary as the tenant boundary and keep every tenant a normal single-operator OpenClaw. This PR adds the v1 supervisor:
openclaw fleet create|list|status|start|stop|restart|upgrade|rm— provisions one cell (a complete OpenClaw instance from the officialghcr.io/openclaw/openclawimage) per tenant, on Docker or Podman.--cap-drop=ALL,no-new-privileges,--init, PID/memory/CPU limits,--restart unless-stopped, per-cell bridge network, gateway port published on127.0.0.1only; neverdocker.sock,--privileged, host networking, or added capabilities./home/node/.openclaw,/home/node/.config/openclaw); user mapping handles rootful/rootless Docker and Podmankeep-id, with SELinux:Zrelabeling when active.upgradefrom container inspection.fleet_cellstable in the shared state DB (Kysely; same zero-config-key pattern as managed worktrees). Per-tenant operation leases reuse the existingstate_leasestable so concurrent CLI mutations of one cell fail fast instead of corrupting container state; failedcreaterolls back only its own attempt-labeled artifacts, and failedupgraderestores the previous container.rm --purge-datarequires--forceand performs realpath containment checks (symlink-swap and sibling-cell escapes refused) before deleting anything.fleetCLI reference. Shared channel ingress, slim per-tenant hosts, remote cells, and a tenant portal are explicitly deferred.No gateway/runtime behavior changes, no new
openclaw.jsonkeys, no new dependencies; personal-mode deployments are untouched.User Impact
Operators get a supported, documented way to host multiple users on one Linux host with a real isolation story and lifecycle UX (
createprints the cell URL and one-time gateway token). Existing single-operator deployments see no behavior change.Evidence
pnpm check:changed) on Blacksmith Testbox: all lanes green except "test temp creation report", which crashes on the delegated sync checkout withfatal: origin/main...HEAD: no merge base— an infrastructure issue unrelated to this diff (the same report over this diff locally returns zero findings in both branch and staged mode); harness fix tracked separately.pnpm buildclean, no[INEFFECTIVE_DYNAMIC_IMPORT]findings.docs:mapregenerated; docs link check passed (5,849 links, 0 broken) in the Codex build pass.gpt-5.6-sol, xhigh) per commit: the test and docs commits reviewed clean apart from accepted findings that are fixed in the follow-up commit; the feat commit surfaced two real P2s — upgrades could commit an immediately-crashing replacement without triggering restore, and a name collision with an unlabeled foreign container/network stranded the tenant reservation unrecoverably. Both fixed (replacement now verified by attempt-label + running-state inspection before the registry update; unlabeled resources treated as provably foreign: left untouched, reservation released) plus five new regression tests; the docs finding (unknownstate also signals ownership mismatch) is documented. A second review round hardened the upgrade gate further: commit now waits for the replacement to answer/healthz(the compose health contract) with fast-fail on exit/restart-loop and a bounded ~60s deadline before restore, so a start-then-crash image cannot displace a healthy cell. Final fix commit reviewed clean ("no accepted/actionable findings", confidence 0.94).