Repository navigation
fix(sandbox): pass --init so tini reaps zombie processes - #74083
luckylhb90 wants to merge 1 commit into
Conversation
Greptile SummaryThis PR adds Confidence Score: 5/5Safe to merge — minimal, well-tested one-line addition using a stable, official Docker feature. The change is a single args.push('--init') call backed by a clear comment and a new dedicated test. --init is a long-standing Docker flag that simply enables the built-in tini shim; it introduces no new attack surface or behavioral change beyond proper zombie reaping. No files require special attention. Reviews (1): Last reviewed commit: "fix(sandbox): pass --init so tini reaps ..." | Re-trigger Greptile |
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Keep open: the branch targets a real sandbox PID-1 zombie issue that current main still has, but it is not merge-ready because it adds the Docker init flag without a recreate/hash rollout for existing long-lived containers and only provides unit-test proof. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Canonical path: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review. So I’m closing this here because the remaining work is already tracked in the canonical issue. Review detailsBest possible solution: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review. Do we have a high-confidence way to reproduce the issue? Yes, source-level: current main creates sandbox containers without Docker Is this the best way to solve the issue? No, not as submitted. Docker Security review: Security review cleared: No concrete security or supply-chain concern found; the diff changes Docker create arguments and tests without dependencies, workflows, secrets, package resolution, or permissions. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against 010b61746379. |
|
Original reporter of #68691 here — confirming the production impact described in this PR's summary. Long-lived OpenClaw sandbox in production: Echoing clawsweeper's P2 (and the parallel review on #68691): the hash-rollout gap is the real blocker for our pattern. With Minimal fix: add a static Happy to test a patched branch with the hash-epoch addition on our long-lived sandbox if it helps maintainers verify the recreate path. |
## Summary Adds `spec.shareProcessNamespace` (default `true`) to `OpenClawInstance`. When enabled, all containers in the pod share a PID namespace and the Kubernetes `pause` container becomes PID 1, automatically reaping zombie processes that accumulate under the Node.js gateway (which does not call `waitpid()` on orphaned children). Closes #471. Supersedes #476 — incorporates @alexander-morris's production-validated approach with the docs, unit tests, e2e tests, and field placement requested in [the review on #476](#476 (review)). ## Background [#471](#471) reported 28 defunct processes accumulating under PID 1 on a production OpenClaw pod (QMD, git, shells, plugin helpers). Image-level fixes (`tini` in the entrypoint) are the most durable long-term solution and are tracked upstream at openclaw/openclaw#74083, but operator users have no clean way to wrap the entrypoint today. PID-namespace sharing is the standard Kubernetes-native answer and stacks harmlessly with a future upstream init process. @alexander-morris validated the approach in production (28 agents, 7+ hours, zero zombie accumulation, zero unrelated restarts on 24/28 pods). ## Changes **Core:** - `api/v1alpha1/openclawinstance_types.go` — `ShareProcessNamespace *bool` with `+kubebuilder:default=true`, placed next to `Security` (pod-level runtime/security cluster) per review feedback on #476. - `internal/resources/statefulset.go` — `shareProcessNamespace()` helper; treats `nil` as `true` so instances stored before the field existed still get the fix on next reconcile. **Generated (do not hand-edit):** - `api/v1alpha1/zz_generated.deepcopy.go` - `config/crd/bases/openclaw.rocks_openclawinstances.yaml` - `charts/openclaw-operator/templates/crds/openclaw.rocks_openclawinstances.yaml` **Tests:** - `internal/resources/resources_test.go` — three new builder cases: default-true (field unset), explicit-true, explicit-false. Pattern matches the existing `AutomountServiceAccountToken` tests. - `test/e2e/e2e_suite_test.go` — two new specs in the controller suite: default-true and explicit-false override. Pattern matches the adjacent `runtimeClassName` spec. **Docs:** - `README.md` — new feature-table row and a "Shared Process Namespace" subsection with opt-out snippet and security trade-off. - `docs/api-reference.md` — `spec.shareProcessNamespace` field reference with type/default/behavior, security implication, and upgrade note about pod-template rollout for existing instances. ## Security trade-off (called out in docs) With sharing enabled, every container in the pod can see and signal every other container's processes. A compromised sidecar (Tailscale, Ollama, browser, custom) could send signals to the gateway and vice versa. For most deployments the zombie-reaping benefit clearly outweighs this; users with mutually-distrusting sidecars can opt out per instance and reap inside their image (`tini`/`dumb-init`). ## Upgrade impact Flipping the default to `true` means every existing `OpenClawInstance` will get a one-time pod-template change on next reconcile, rolling pods. Operators running large fleets should plan a maintenance window. Called out in the api-reference upgrade note. ## Test plan - [x] `go test ./internal/resources/` passes (3 new tests covering default/true/false) - [x] `make lint` passes (golangci-lint v1.64.5) - [x] `go vet ./...` clean - [x] `make generate manifests sync-chart-crds` regenerates cleanly (no manual edits to generated files) - [ ] E2E suite passes in CI on a real kind cluster (new specs follow the existing `runtimeClassName` pattern) ## Credit Production validation and original PR by @alexander-morris in #476. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: alexander-morris <[email protected]> Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
|
This pull request has been automatically marked as stale due to inactivity. |
|
This pull request has been automatically marked as stale due to inactivity. |
|
Thank you @luckylhb90 — this fix has landed on The final version keeps The original fork head was too stale for the safe maintainer GraphQL update path without generating a repository-wide payload, so the reviewed one-commit version was carried in the maintainer replacement. Closing this PR as superseded by the landed fix. |
Summary
What: Adding --init to the docker sandbox makes tini the PID 1 and reaps zombie processes.
Why: Long-running sandboxes generate a large number of short-lived child processes (shell/browser helpers), and the entrypoint does not reap them → processes accumulate → kernel.pid_max is exhausted → subsequent fork/exec fails.
Evidence: A new test was added to assert that --init appears in the output of buildSandboxCreateArgs and is placed after create; all 17 local tests passed.
Risk: Extremely low, --init is an official Docker feature, and the daemon comes with tini.
Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause (if applicable)
For bug fixes or regressions, explain why this happened, not just what changed. Otherwise write
N/A. If the cause is unclear, writeUnknown.Regression Test Plan (if applicable)
For bug fixes or regressions, name the smallest reliable test coverage that should catch this. Otherwise write
N/A.User-visible / Behavior Changes
List user-visible changes (including defaults/config).
If none, write
None.Diagram (if applicable)
For UI changes or non-trivial logic flows, include a small ASCII diagram reviewers can scan quickly. Otherwise write
N/A.Security Impact (required)
Yes/No)Yes/No)Yes/No)Yes/No)Yes/No)Yes, explain risk + mitigation:Repro + Verification
Environment
Steps
Expected
Actual
Evidence
Attach at least one:
Human Verification (required)
What you personally verified (not just CI), and how:
Review Conversations
If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.
Compatibility / Migration
Yes/No)Yes/No)Yes/No)Risks and Mitigations
List only real risks for this PR. Add/remove entries as needed. If none, write
None.