Skip to content

typedocs-only PR to help others avoid kubernetes OOM-kills - #96828

Closed
navicore wants to merge 2 commits into
openclaw:mainfrom
navicore:container-mem-doc
Closed

navicore wants to merge 2 commits into
openclaw:mainfrom
navicore:container-mem-doc

Conversation

@navicore

@navicore navicore commented Jun 25, 2026 •

Copy link
Copy Markdown

docs(k8s) OOM-kills happen when openclaw runs its various node tools when k8s limits are set.

What Problem This Solves

on kubernetes, OOM-kills happen when openclaw runs its various node tools when k8s limits are set.

Why This Change Was Made

This documentation and example would have saved me the time it took to debug and discover the node setting needed to stop node from trying to gobble up more resources than allowed.

The crash is especially hard to recover from because upon automatic restart the agent goes into a blocking unresponsive state with no logging due to the gateway lock loop state the OOM-kill puts the container into - also observed in the fly fix #1572

User Impact

The impact is avoiding the fatal crash that happens when the agent runs its node-based tools for purposes such as status/healthcheck.

Evidence

  1. The change in the example deployment.yaml fixed the issue for me locally.
  2. Fix is modeled after the existing openclaw fly docs and examples as fly container orchestration has the same exposure to this issue and solved it specific for fly. fix: handle PID recycling in container gateway lock #1572
  • deploy/fly.private.toml:22 — NODE_OPTIONS = "--max-old-space-size=1536" (the actual config)
  • docs/install/fly.md:59 — same line, in the Fly install doc
  1. proof that making these changes fixed the OOM kills is the pods started with the fix kept running instead of immediately getting killed. Console from today showing the pods ran for 2 days before some unrelated cluster node changes w/o incident:
☁  ~ k -n dooc get po
NAME                             READY   STATUS    RESTARTS      AGE
dooc1-openclaw-cb587d4b4-dwj4s   1/1     Running   1 (11d ago)   13d
dooc2-openclaw-5bb4bc746-2nxbl   1/1     Running   1 (11d ago)   13d

OOM-kills happen when openclaw runs its various node tools when k8s
limits are set.

1. scripts/k8s/manifests/deployment.yaml — added
   NODE_OPTIONS=--max-old-space-size=1536 to the gateway container env,
   with a comment explaining the cgroup/heap mismatch. Placed right
   after NODE_ENV, before the secret-backed vars.

2. docs/install/kubernetes.md — added a "Memory and the Node heap"
   subsection under Customization, explaining why the cap exists and the
   keep-in-sync rule.

Fix is modeled after the existing fly docs and examples.
- deploy/fly.private.toml:22 — NODE_OPTIONS = "--max-old-space-size=1536" (the actual config)
- docs/install/fly.md:59 — same line, in the Fly install doc
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts size: XS labels Jun 25, 2026
@clawsweeper

clawsweeper Bot commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed July 8, 2026, 11:00 AM ET / 15:00 UTC.

Summary
The PR adds Kubernetes documentation for Node heap sizing and sets NODE_OPTIONS=--max-old-space-size=1536 in the sample Kubernetes deployment manifest.

PR surface: Docs +10, Other +6. Total +16 across 2 files.

Reproducibility: yes. for the review blockers: the PR diff still contains Node/cgroup wording contradicted by current Node/libuv source, and the committed docs map is missing the new heading. The original Kubernetes OOM is supported by contributor kubectl output but was not independently reproduced here.

Review metrics: 1 noteworthy metric.

  • Kubernetes runtime env default: 1 added. The sample manifest would start carrying a fixed NODE_OPTIONS heap cap, which maintainers should review as an inherited deployment default before merge.

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🐚 platinum hermit
Patch quality: 🦐 gold shrimp
Result: needs maintainer review before merge.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Correct the Node/cgroup wording in both changed files.
  • Regenerate and include docs/docs_map.md for the new docs heading.
  • Get maintainer acceptance for the fixed Kubernetes heap cap or narrow it to optional guidance.

Risk before merge

  • [P1] Merging as-is would put a fixed 1536 MiB V8 heap cap into the public Kubernetes manifest; operators who change the 2Gi pod limit without changing the cap can inherit confusing V8 heap or pod OOM behavior.
  • [P1] The Kubernetes manifest change partially overlaps open daemon heap-default work in fix(daemon): prevent gateway OOM crash loops under sustained load #96250, but it affects a different deployment path, so maintainers should explicitly align or separate the policy.

Maintainer options:

  1. Correct wording and keep the Kubernetes cap (recommended)
    Reword the docs and manifest comment around container headroom rather than cgroup ignorance, regenerate the docs map, and merge only if maintainers accept the fixed 1536 MiB default.
  2. Convert the cap to opt-in guidance
    Remove the manifest env default and keep the heap-size value in docs or an overlay example for clusters that need it.
  3. Pause for broader heap-default direction
    Hold this PR if maintainers want one settled policy for daemon and Kubernetes heap defaults before changing public deployment manifests.

Next step before merge

  • [P2] The PR needs contributor or maintainer edits for the two concrete docs findings plus a human decision on the fixed Kubernetes default, so it is not a safe automated repair lane as-is.

Maintainer decision needed

  • Question: Should the shared Kubernetes manifest ship a fixed 1536 MiB NODE_OPTIONS heap cap, or should this PR only document an optional operator overlay?
  • Rationale: The diff changes a public deployment default, not just explanatory docs, and that default creates a keep-in-sync requirement when Kubernetes memory limits change.
  • Likely owner: steipete — The decision is closest to the Fly/container deployment precedent, the cited container lock work, and recent docs ownership.
  • Options:
    • Ship the cap after corrections (recommended): Keep the manifest default because it matches the existing 2Gi limit and Fly precedent, but require accurate wording, regenerated docs map, and review of the keep-in-sync guidance before merge.
    • Make it optional guidance: Remove the manifest default and document an overlay/example so operators opt in when their Kubernetes limits and workload need it.
    • Defer to heap-default policy: Pause this PR until maintainers decide how it should align with the broader daemon heap default work in fix(daemon): prevent gateway OOM crash loops under sustained load #96250.

Security
Cleared: The diff adds docs text and a fixed Node heap-size environment value only; no concrete supply-chain, secret, permission, or new code-execution concern was found.

Review findings

  • [P2] Correct the Node cgroup heap explanation — docs/install/kubernetes.md:145-147
  • [P2] Regenerate the docs map for the new heading — docs/install/kubernetes.md:143
Review details

Best possible solution:

Land only after correcting the Node/container-memory explanation, regenerating docs/docs_map.md, and having a maintainer accept whether the shared Kubernetes manifest should ship the fixed heap cap or document it as an optional overlay.

Do we have a high-confidence way to reproduce the issue?

Yes for the review blockers: the PR diff still contains Node/cgroup wording contradicted by current Node/libuv source, and the committed docs map is missing the new heading. The original Kubernetes OOM is supported by contributor kubectl output but was not independently reproduced here.

Is this the best way to solve the issue?

No as written. The heap cap is a plausible mitigation, but the best solution must describe the real container-headroom tradeoff, keep generated docs aligned, and get maintainer acceptance for the manifest default.

Full review comments:

  • [P2] Correct the Node cgroup heap explanation — docs/install/kubernetes.md:145-147
    This still says Node's V8 heap is sized from host RAM and ignores cgroup limits, and the manifest comment repeats that claim. Current Node v24 calls uv_get_constrained_memory(), with libuv reading cgroup memory limits, so please reframe this around reserving container headroom under the pod limit or remove the cgroup-ignorance claim in both changed files.
    Confidence: 0.9
  • [P2] Regenerate the docs map for the new heading — docs/install/kubernetes.md:143
    docs/AGENTS.md marks docs/docs_map.md as generated, and adding ### Memory and the Node heap leaves the committed map missing that heading. CI check-docs reports docs/docs_map.md is out of date, so include the regenerated map with this docs change.
    Confidence: 0.92

Overall correctness: patch is incorrect
Overall confidence: 0.9

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 9d7a6b5da61b.

Label changes

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body now includes copied kubectl output showing the author's Kubernetes pods running after the change; this is sufficient real setup proof for the claimed after-fix behavior, though not a full independent OOM reproduction.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The PR body now includes copied kubectl output showing the author's Kubernetes pods running after the change; this is sufficient real setup proof for the claimed after-fix behavior, though not a full independent OOM reproduction.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: ⏳ waiting on author.

Label justifications:

  • P2: The PR affects Kubernetes deployment reliability guidance and a public sample manifest default with limited but real operator impact.
  • merge-risk: 🚨 compatibility: Merging adds a fixed runtime environment default that Kubernetes users may inherit when updating deployment manifests.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The PR body now includes copied kubectl output showing the author's Kubernetes pods running after the change; this is sufficient real setup proof for the claimed after-fix behavior, though not a full independent OOM reproduction.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body now includes copied kubectl output showing the author's Kubernetes pods running after the change; this is sufficient real setup proof for the claimed after-fix behavior, though not a full independent OOM reproduction.
Evidence reviewed

PR surface:

Docs +10, Other +6. Total +16 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 0 0 0 0
Docs 1 10 0 +10
Config 0 0 0 0
Generated 0 0 0 0
Other 1 6 0 +6
Total 2 16 0 +16

What I checked:

  • Live PR state: Live GitHub PR view shows head c5d10db6256e07f0953a3d6ac88cbc67299d29f1, matching the previous reviewed head; the author updated the PR body with copied kubectl proof output rather than changing the patch. (c5d10db6256e)
  • PR adds fixed Kubernetes heap env: The PR diff adds NODE_OPTIONS=--max-old-space-size=1536 to the gateway container environment, so this is a public deployment default change, not docs-only text. (scripts/k8s/manifests/deployment.yaml:70, c5d10db6256e)
  • Current main Kubernetes behavior: Current main has a 2Gi gateway memory limit and no Kubernetes NODE_OPTIONS heap cap, so the PR is not already implemented on main. (scripts/k8s/manifests/deployment.yaml:104, 9d7a6b5da61b)
  • Latest release behavior: Latest release v2026.6.11 also has the 2Gi Kubernetes limit without a Kubernetes heap cap, while the Fly template in that release uses the same 1536 MiB value as precedent. (scripts/k8s/manifests/deployment.yaml:104, e085fa1a3ffd)
  • Node dependency contract: Node v24 calls uv_get_constrained_memory() and configures V8 defaults from the constrained memory when available, contradicting the PR wording that Node ignores cgroup limits. (nodejs/node:src/api/environment.cc:211)
  • libuv dependency contract: libuv v1.x reads cgroup v1/v2 memory limits and returns the minimum cgroup/rlimit constraint from uv_get_constrained_memory(). (libuv/libuv:src/unix/linux.c:2214)

Likely related people:

  • sallyom: GitHub path history shows 8e0e4f736a862a8c24e88a74276ce41ea1d9c27e added the Kubernetes install guide and manifests that this PR changes. (role: introduced Kubernetes install surface; confidence: high; commits: 8e0e4f736a86; files: docs/install/kubernetes.md, scripts/k8s/manifests/deployment.yaml, scripts/k8s/deploy.sh)
  • steipete: History and related PR context tie Peter Steinberger to the cited Fly/container precedent, the recent docs rewrite, and the merged container gateway lock fix referenced by this PR. (role: adjacent container deployment contributor; confidence: medium; commits: f7d7148cf047, 3fff943ba1bb, 1f1686bc4d94; files: docs/install/kubernetes.md, docs/install/fly.md, deploy/fly.private.toml)
  • vincentkoc: Commit history for the Kubernetes docs page includes docs heading/frontmatter hygiene work that is adjacent to the generated-map and docs-anchor concern. (role: recent docs hygiene contributor; confidence: medium; commits: 411211c21b3d, b70d1aae57bc; files: docs/install/kubernetes.md, docs/docs_map.md)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (2 earlier review cycles)
  • reviewed 2026-06-25T16:52:20.004Z sha 0d6ff01 :: needs real behavior proof before merge. :: [P2] Correct the cgroup heap explanation
  • reviewed 2026-07-08T14:49:45.138Z sha c5d10db :: found issues before merge. :: [P2] Correct the Node cgroup heap explanation | [P2] Regenerate the docs map for the new heading

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jun 25, 2026
@clawsweeper

clawsweeper Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

@navicore thanks for the PR. ClawSweeper is still waiting on real behavior proof before this can move forward.

Useful proof can be a screenshot, short video, terminal output, copied live output, linked artifact, or redacted logs that show the changed behavior after the fix. Please redact private tokens, phone numbers, private endpoints, customer data, and anything else sensitive.

Once proof is added to the PR body or a comment, ClawSweeper or a maintainer can re-check it.

@navicore

navicore commented Jul 8, 2026 •

Copy link
Copy Markdown
Author

updated body with evidence 3 item including kubectl output showing pods continuing to run w/ change.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 8, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jul 23, 2026
@navicore navicore closed this Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: XS stale Marked as stale due to inactivity status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant