Repository navigation
feat: shareProcessNamespace (default true) to reap zombies - #485
Merged
Merged
Conversation
Long-running gateway pods accumulate zombie processes from QMD memory, git, plugins, and shells because the Node.js gateway runs as PID 1 and does not call waitpid() on orphaned children. With shareProcessNamespace enabled, the Kubernetes pause container becomes PID 1 and reaps zombies automatically, no custom init/reaper image required. Defaults to true so existing instances get the fix on next reconcile. Users that need per-container PID isolation can opt out per instance. Co-Authored-By: alexander-morris <[email protected]> Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
stubbi
added a commit
that referenced
this pull request
May 12, 2026
🤖 I have created a release *beep* *boop* --- ## [0.33.0](v0.32.1...v0.33.0) (2026-05-12) ### Features * shareProcessNamespace (default true) to reap zombies ([#485](#485)) ([4cbfd4d](4cbfd4d)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
spec.shareProcessNamespace(defaulttrue) toOpenClawInstance. When enabled, all containers in the pod share a PID namespace and the Kubernetespausecontainer becomes PID 1, automatically reaping zombie processes that accumulate under the Node.js gateway (which does not callwaitpid()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.
Background
#471 reported 28 defunct processes accumulating under PID 1 on a production OpenClaw pod (QMD, git, shells, plugin helpers). Image-level fixes (
tiniin 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 *boolwith+kubebuilder:default=true, placed next toSecurity(pod-level runtime/security cluster) per review feedback on feat: add shareProcessNamespace to pod spec (defaults to true) #476.internal/resources/statefulset.go—shareProcessNamespace()helper; treatsnilastrueso instances stored before the field existed still get the fix on next reconcile.Generated (do not hand-edit):
api/v1alpha1/zz_generated.deepcopy.goconfig/crd/bases/openclaw.rocks_openclawinstances.yamlcharts/openclaw-operator/templates/crds/openclaw.rocks_openclawinstances.yamlTests:
internal/resources/resources_test.go— three new builder cases: default-true (field unset), explicit-true, explicit-false. Pattern matches the existingAutomountServiceAccountTokentests.test/e2e/e2e_suite_test.go— two new specs in the controller suite: default-true and explicit-false override. Pattern matches the adjacentruntimeClassNamespec.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.shareProcessNamespacefield 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
truemeans every existingOpenClawInstancewill 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
go test ./internal/resources/passes (3 new tests covering default/true/false)make lintpasses (golangci-lint v1.64.5)go vet ./...cleanmake generate manifests sync-chart-crdsregenerates cleanly (no manual edits to generated files)runtimeClassNamepattern)Credit
Production validation and original PR by @alexander-morris in #476.
🤖 Generated with Claude Code