Set GOMEMLIMIT from container memory limit#319
Conversation
📝 WalkthroughWalkthroughThe controller-manager Deployment template adds a ChangesGOMEMLIMIT Configuration
Estimated code review effort: 1 (Trivial) | ~3 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Merging this branch will increase overall coverage
Coverage by fileChanged files (no unit tests)
Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code. Changed unit test files
|
There was a problem hiding this comment.
Pull request overview
This PR updates the Helm deployment for the controller-manager to set GOMEMLIMIT from the container’s configured memory limit so the Go GC can respect cgroup/container limits and reduce OOM-kill risk.
Changes:
- Add a
GOMEMLIMITenvironment variable to the controller-manager container, sourced fromlimits.memoryviaresourceFieldRef.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Without GOMEMLIMIT the Go GC is unaware of the container limit and may let the heap grow until the kernel OOM-kills the process.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
charts/openstack-hypervisor-operator/templates/deployment.yaml (1)
50-54: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winLeave headroom in
GOMEMLIMIT
charts/openstack-hypervisor-operator/templates/deployment.yaml:50-54setsGOMEMLIMITtolimits.memoryexactly. Go still needs room for stacks, cgo, and other non-heap memory, so this can still OOM-kill the container. Set it to ~85–90% of the pod memory limit instead.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@charts/openstack-hypervisor-operator/templates/deployment.yaml` around lines 50 - 54, The GOMEMLIMIT setting in the deployment template is using the full memory limit, leaving no room for non-heap usage. Update the deployment’s GOMEMLIMIT environment variable in the pod spec to use a fraction of the container memory limit (around 85–90%) instead of mapping directly to limits.memory. Use the existing GOMEMLIMIT env entry in the deployment template to make the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@charts/openstack-hypervisor-operator/templates/deployment.yaml`:
- Around line 50-54: The GOMEMLIMIT env in the deployment template is always
rendered through resourceFieldRef, which can silently fall back to node
allocatable memory if controllerManager.manager.resources.limits.memory is
removed by overrides. Update the deployment.yaml logic around the GOMEMLIMIT
entry to only emit it when a memory limit exists, or add a chart guard that
checks the manager resources limit before rendering this env var so it stays
tied to the container limit.
---
Nitpick comments:
In `@charts/openstack-hypervisor-operator/templates/deployment.yaml`:
- Around line 50-54: The GOMEMLIMIT setting in the deployment template is using
the full memory limit, leaving no room for non-heap usage. Update the
deployment’s GOMEMLIMIT environment variable in the pod spec to use a fraction
of the container memory limit (around 85–90%) instead of mapping directly to
limits.memory. Use the existing GOMEMLIMIT env entry in the deployment template
to make the change.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 44971fd1-a88b-473d-825c-cabb87613c2a
📒 Files selected for processing (1)
charts/openstack-hypervisor-operator/templates/deployment.yaml
Without
GOMEMLIMITthe Go GC is unaware of the container limit and maylet the heap grow until the kernel OOM-kills the process.
Summary by CodeRabbit