Repository navigation
fix: let Git checkouts inside containers update again - #203586
fuller-stack-dev wants to merge 8 commits into
Conversation
A container marker alone no longer refuses a Git update. A checkout cloned into a container updates as before openclaw#203194, and the run records a warning:preflight step saying that anything outside mounted volumes is reset when the container is recreated. Image installs stay skipped by the existing container-image-install admission.
|
RED raw logs: base RED refused: exit 1, stdout{
"runId": "c04c7e38-1b5f-4e36-8787-fc4714e58b72",
"createdAtMs": 1795367847731,
"updatedAtMs": 1795367847978,
"trigger": "api",
"phase": "finished",
"status": "failed",
"reason": "container-install",
"origin": {
"deliveryContext": {
"channel": "webchat"
},
"nextAction": "This installation belongs to a container image. Update the image instead.",
"cause": "unknown"
},
"target": {
"kind": "git",
"version": "2026.11.6",
"sha": "fe6f54abf2e17c8ec83ebe6d9173eec62206f32b"
},
"before": {
"version": "2026.11.6"
},
"after": {},
"steps": [
{
"step": "requested",
"status": "completed",
"startedAtMs": 1795367847731,
"endedAtMs": 1795367847970
},
{
"step": "notice:ack",
"status": "skipped",
"endedAtMs": 1795367847818,
"detail": "no delivery target"
},
{
"step": "staging",
"status": "failed",
"startedAtMs": 1795367847970,
"endedAtMs": 1795367847978,
"failureFacts": [
{
"check": "update",
"code": "update-failed"
}
]
}
],
"verification": {
"noticeDelivered": false
},
"repair": [],
"confirmedAtMs": null,
"finishedAtMs": 1795367847978,
"downtimeMs": null
}RED refused-again: exit 1, stdout{
"runId": "e89d1988-d918-45a8-b027-e541945b5ac2",
"createdAtMs": 1795367853113,
"updatedAtMs": 1795367853248,
"trigger": "api",
"phase": "finished",
"status": "failed",
"reason": "container-install",
"origin": {
"deliveryContext": {
"channel": "webchat"
},
"nextAction": "This installation belongs to a container image. Update the image instead.",
"cause": "unknown"
},
"target": {
"kind": "git",
"version": "2026.11.6",
"sha": "fe6f54abf2e17c8ec83ebe6d9173eec62206f32b"
},
"before": {
"version": "2026.11.6"
},
"after": {},
"steps": [
{
"step": "requested",
"status": "completed",
"startedAtMs": 1795367853113,
"endedAtMs": 1795367853234
},
{
"step": "notice:ack",
"status": "skipped",
"endedAtMs": 1795367853156,
"detail": "no delivery target"
},
{
"step": "staging",
"status": "failed",
"startedAtMs": 1795367853234,
"endedAtMs": 1795367853248,
"failureFacts": [
{
"check": "update",
"code": "update-failed"
}
]
}
],
"verification": {
"noticeDelivered": false
},
"repair": [],
"confirmedAtMs": null,
"finishedAtMs": 1795367853248,
"downtimeMs": null
}Control: same cell after only
|
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
…hen state outlives the image The Git update.run route now refuses an externally supervised Gateway with external-supervisor-update-required, as the package route and automatic updates do. The container warning also says that an image recreated with its original build may refuse upgraded state.
|
Codex review: needs maintainer review before merge. What this changesThis PR lets Git checkouts inside containers update with a persistence warning while preserving image-install and external-supervisor restrictions. Example: A Git checkout on a mounted volume runs openclaw update inside Docker with /.dockerenv present.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenanceRegression provenance — verified: source commit Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR addresses a confirmed update regression still present on main, with no definite introduced code defect found. Priority: P1 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe update subsystem receives CLI, Gateway, and automatic update requests, checks installation ownership and prerequisites, prepares a release, and hands activation to the resident launcher. flowchart TD
A[CLI or automatic update] --> C[Update admission]
B[Gateway update request] --> C
C --> D[Git update preflight]
D --> E[Warning in update ledger]
D --> F[Prepare and validate release]
F --> G[Launcher trial and Gateway restart]
Technical reviewBest possible solution: Keep the focused preflight warning and existing installation-ownership checks, with release preparation and activation remaining under their current owners. Do we have a high-confidence way to reproduce the issue? The current-main preflight directly establishes the failure for /.dockerenv, and the contributor supplied matching refusal logs plus a successful marker-removed control; this review ran no target code. Is this the best way to solve the issue? The patch fixes the mistaken environment-based refusal at its existing owner, preserves the other prerequisite checks, and adds focused coverage without new production machinery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 34ce936db81e. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +28, Tests +63, Docs +7. Total +98 across 7 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 22, 2026, 1:39 PM ET / 18:39 UTC. |
|
GREEN raw logs: PR head GREEN update: exit 0, 380.4 sGREEN noop: exit 0, 6.5 sGREEN image-shape: exit 0, 4.1 sPer-step summary: Gateway outages and per-directory diskMarker rows, hash and quick_check before and after |
…into a release update.run and automatic Git updates refuse with restart-unavailable when the Gateway is a container's main process without a supervisor, because the detached successor would stop the container. The message names --no-restart and a container restart. A CLI that stops following a run still prints its container warning.
…in process A Gateway started with docker exec has no parent inside the container and hands off to a detached successor as on a host; only PID 1 or a direct child of the container's init shim or shell is refused.
|
Recordings: live terminal captures of the same cell on base and on the PR head RED, base red-container-checkout-base-a1aa127.mp4GREEN, head green-container-checkout-head-a631d99.mp4GREEN at head update: exit 0, 369.8 s (raw stdout)GREEN at head noop: exit 0, 6.5 s (raw stdout)GREEN at head image-shape: exit 0, 4.3 s (raw stdout)Per-step outages, disk and marker checks at head |
|
Closing: #203735 (merged as 58a3c7e) removed the blanket container refusal from Two things from this PR are not covered by #203735 and are left as possible follow-ups, not carried here:
The raw logs in the comments above are from the earlier head and from main before #203735. |
What Problem This Solves
Since #203194,
openclaw updaterefuses every Git checkout on a host that has/.dockerenv(orcontainer,DOCKER_CONTAINERorOPENCLAW_CONTAINERset). It fails withcontainer-install, "This installation belongs to a container image. Update the image instead." A checkout that someone cloned and built inside a container or devbox is not part of any image, and the updater before #203194 updated it. Today it cannot update at all, and the next action it names is wrong for it.User Impact
A Git checkout inside a container updates through
openclaw update,update.runand automatic updates like any other checkout. The run records awarning:preflightstep, andopenclaw updateprints it: whatever is not on a mounted volume is reset when the container is recreated from its image, so keep the checkout and the state directory on volumes or build the new version into the image. If only the state directory is on a volume, the warning also says that the image's original build may refuse the upgraded state after a recreate. Nothing else changes. OpenClaw's own image is a package install and is still skipped withcontainer-image-install. Nix and Homebrew refusals are unchanged.A Gateway with
OPENCLAW_SUPERVISOR_MODE=externalnow refusesupdate.runon a Git install withexternal-supervisor-update-required, as the package route,openclaw updateand automatic updates already do. #203194's Git route had dropped that check, and container deployments are where external supervisors are common.A Gateway that is a container's main process, with no service manager or launcher above it, cannot start a new release without stopping the container: the update restart hands off to a detached successor and exits, which ends the container.
update.runand automatic Git updates now refuse that case withrestart-unavailablebefore anything is prepared, and the message names the step that works:openclaw update --no-restartin the container, then restart the container. "Main process" means PID 1 or a direct child of the container's init shim or shell, since that exit ends the container. A Gateway started withdocker exechas no parent inside the container and hands off as it does on a host. A Gateway under systemd, launchd or the release launcher inside a container is also unaffected; the green cell below is that case.Why This Change Was Made
Why the refusal existed. It came in with #203194 as one preflight line ("container installs refused before any change"). I found no other reasoning for it in the PR description, the review thread or the docs. The case where it is right is an install that lives in the image layer, where an in-place change is lost when the container is recreated.
Evidence that the line cannot see that case.
src/update/preflight.tsruns only for Git installs on main. Every caller ofprepareUpdateroutesinstallKind === "git":update-command.ts,update-run.tsandupdate-startup-auto-run.ts.Dockerfile) ships a package at/appwith no.git. The existing update-command admission already skips it ascontainer-image-install(resolveUnmanagedUpdateInstallReason), beforesrc/updateis reached.OPENCLAW_CONTAINERas evidence of a container. That variable is the host-side--container <name>target (src/cli/container-target.ts), and inside the container the CLI clears it.Rule. A container signal alone never refuses. Preflight uses the existing detector,
isContainerEnvironment()(/.dockerenv,/run/.containerenv, container cgroups, Fly). Inside a container it continues and returns a warning, which the run records. Every refusal that follows (Nix, Homebrew, writable prefix, tools, dirty checkout, Node engine, disk space) still applies, in the same order.What stays refused. An image-owned install: the official image, and any package root without a package-manager owner. Those are skipped by the existing admission owner with "Pull or build the target Docker/container image, then redeploy it with the same state/config mounts". The green cell below checks this.
Alternatives rejected.
Update behavior. This changes the updater inside the release path, so it applies once the installed CLI or Gateway has this code. An installed build from #203194 (merged 2026-11-22, main only) up to this change still refuses its next update inside a container, because the refusal runs in the installed code. That one hop cannot be patched from here. Remove
/.dockerenvas root for that update (Docker recreates it with the container), which is the control row below, or pull and build the checkout by hand once. Every later update uses this rule. No schema, config, protocol, dependency or retention change.Evidence
Real Linux container with systemd as PID 1, a lingering user manager and a real user bus. A user systemd Gateway service, a Gateway-gated writer on a 256–512 MiB agent database, and 1,000 marker rows checked by count, SHA-256 and
PRAGMA quick_checkafter every step. Synthetic state only. The checkout was cloned and built inside the container, and its home is a volume./.dockerenva1aa1276017container-install, "Update the image instead"; Gateway untouchedsucceeded, serving the target builda631d9991b9succeeded, serving the target build,warning:preflightrecordedalready-currentskipped,container-image-install, "Pull or build the target Docker/container image...""Data intact" means the 1,000 marker rows kept the same count and SHA-256 (
69cb2f12…), andquick_checkreturnedokbefore and after every step. The same green rows also passed at two earlier heads:039ac631f2d(369 s, 11.8 s outage) and91087630aff(380 s, 11.8 s outage).Red and green terminal recordings, and the raw head output: recordings and green raw logs at the head. Raw red and control output: red and control. Full logs are not attached because the artifact store rejects uploads from this machine.
Tests (
src/update/prepare.test.ts):runReleaseUpdateCliwith a real Git fixture and state database. It ends with a pending trial and exit 0, records the warning, and prints it. The fixture presents both container signals, the shared detector and the/.dockerenvmarker the base preflight reads, so on the base it fails withstatus: failed(container-install).update-run.test.ts): a Gateway that is a container's main process refusesupdate.runwithrestart-unavailableand the--no-restartnext step, and prepares nothing (red on the base handler, which accepted the run). Negative controls: the same container under a supervisor (the release launcher) prepares the release, and so does a Gateway started withdocker exec.update-run.test.ts): an externally supervised Gateway answersupdate.runwithexternal-supervisor-update-requiredand prepares nothing. Red on the base handler, which accepted the run./.dockerenvfs.accessspy and thecontainer/DOCKER_CONTAINER/OPENCLAW_CONTAINERstubs. Production no longer reads them. The module mock ofisContainerEnvironmentreplaces them, so no case depends on the host's container status. Also removed: the old "refuses a Docker marker" case, whose behavior is retired on purpose.Checks:
node scripts/run-vitest.mjs src/update/ src/gateway/server-methods/update-run.test.ts(44 passed),pnpm tsgo:core,pnpm tsgo:core:test, oxlint and oxfmt on the touched files,pnpm check:baseline-ratchets(all ok, including session-identity, mock-exports and test-lines +42),pnpm check:docs,git diff --check.Review: ClawSweeper's local review round 3 rated overall F, proof C, patch F. Its findings, and what I did:
sleep infinitywould be refused. Fixed: the refusal now needs PID 1 or a direct child of PID 1.container=systemd-nspawngoes undetected, where main used to refuse it. Not changed: the shared detector does not read that variable, and adding it would change every caller of the detector. Listed under "Not proven".restart-unavailableto package wording. Not changed: that is a UI change, and it needs its own screenshots.skippedrefusal outside the failure backoff. Not changed: the refusal happens before anything is prepared and costs one check.Round 2 raised the container main-process restart (fixed above) and asked that
openclaw updateprint the warning even when it stops following a run at its--timeout(done, covered incli.test.ts). Round 1 raised the supervisor gap (fixed above), asked that the warning cover a recreated image refusing upgraded state (added), and asked that the regression test exercise the base's own signal (done).autoreviewcannot run here. The worktree sits under a shared temp directory, and its Codex preflight refuses that. A fresh independent reviewer found no P0 or P1 issues. Its two P2 findings are fixed: the step is now awarning:step, so reports, the Control UI and the warning headline show it, and the negative control above is new.Not proven:
--no-restart, then restart-the-container path is not run.describeUpdateRestartUnavailable); that caller has no test of its own.checks-node-changed-compact-large-9-1fails onsrc/flows/doctor-health.legacy-update.test.ts, three cases. They fail the same way onmainwithout this change, and open PRs chore(test): align latent-red tests with one-time admission and no-auto-disable cron #203560 and fix: restore two OpenClaw regression suites #203569 fix them. Main will be merged in once they land.