OCPNODE-4895: Turn off cgroup v2 memory_hugetlb_accounting before CRI-O and the kubelet start #6786
All Vouch review confidence checks passed
Residual risk 0.40 = Change Risk (0.75) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.75 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.344
Sensitive Paths
sensitive_paths
0.075
Real PR Conversation Timeline
1 comments
"Review active on #6786"
general
weight: 0.35
haircommander
- What I did
Added a unit to the base templates,
cgroup2-no-hugetlb-accounting.service, that turns the cgroup v2 mount optionmemory_hugetlb_accountingoff before CRI-O and the kubelet start.Why:
memory.max(kernel documentation).memory.maxfrom the memory limit alone, for the pod and for each container. So a pod that uses hugepages and ordinary memory together is OOM-killed, or hangs, below its memory limit. Details and measurements: https://github.com/kubernetes/kubernetes/issues/144131 and https://harche.github.io/2026/11/23/notes-on-kubernetes-issue-144131-hugepages.htmlmount-setup.cin v259, systemd/systemd#39486) and have no way to turn it off.rhel-9.10.0) and RHEL 10 (systemd 257, mount options inrhel-10.4) do not set it, so nodes are not affected today.Pods that have a memory limit far below their hugepages, and so would fail as soon as they touch them (read from upstream sources, not run):
WithHugePages,WithCPUPinning). The common instance typescx1,n1andrt1are of this kind.hugepages-1Gi: 4Giwithmemory: 1Gi(SR-IOV DPDK example) andhugepages-1Gi: 8Giwithmemory: 2Gi(base workload).Other pods that use hugepages fail only when hugepages plus ordinary memory exceed the memory limit. Pods without a memory limit do not fail.
What the unit does:
ExecConditionskips the unit. No remount happens, and the unit shows as skipped, not failed.cgroup_reconfigure), so the unit reads the current options and passes the others again.failedstate.This is a guard, to be removed when the node has another way to keep the option off.
- How to verify it
On a node where the option is not set (every node today):
On a node where the option is set at boot:
What I tested:
On OpenShift clusters from cluster-bot (GCP, 5.1.0-ec.2 payload with this PR's MCO; RHCOS 10.2, kernel 6.12, systemd 257, CRI-O 1.36 with crun):
5e3a02e7, withExecCondition). The cluster was built from the first version; on one master and one worker, a drop-in set the newExecConditionandExecStart, so the unit ran exactly what the current version runs.- Option not set, after draining and rebooting both nodes: the unit was skipped (
inactive (dead) (Result: exec-condition)), about 8 s into boot, before CRI-O and the kubelet started at 22 to 24 s. Mount options stayedrw,nosuid,nodev,noexec,relatime,seclabel. No failed units, CRI-O and the kubelet active, the nodes came back Ready, and the pools stayed Updated.- Option set by hand together with
nsdelegateandmemory_recursiveprot, then the unit started: onlymemory_hugetlb_accountingwas removed, the other options were kept, and the unit wasactive (exited). Started again: skipped.- The hugepages pod below: completes without the option, OOM-killed with it, completes again once the unit has removed it.
0bfd7b0c, the "nothing to do" check insideExecStart), delivered by the MCO to the master and worker pools at install. Results: https://github.com/openshift/machine-config-operator/pull/6786#issuecomment-7225819220- Option not set, on all 3 masters and 3 workers: the unit ran at boot before CRI-O and the kubelet, did not remount and exited 0. Mount options stayed
rw,nosuid,nodev,noexec,relatime,seclabel. Same after draining and rebooting a worker. Pools stayed Updated and all cluster operators stayed healthy.- Option set by hand, then the unit restarted: only
memory_hugetlb_accountingwas removed.nosuid,nodev,noexec,nsdelegateandmemory_recursiveprotwere kept. Running it again does nothing.- A pod with a 256Mi memory limit and 128Mi of 2Mi hugepages that uses all its hugepages and 192Mi of ordinary memory: it completes without the option, is OOM-killed by the kernel with the option, and completes again once the unit has removed the option.
Elsewhere:
- Booted with the option set: the unit removed it 1.8 s into boot, before the container runtime started at 3.1 s.
nsdelegateandmemory_recursiveprotwere kept.- Started by hand with one more option set (
favordynmods): that option was kept too.- Started by hand with the option not set: no remount.
TestCgroup2NoHugetlbAccountingUnitInEveryRole(new) passes for every platform in the test data, and fails when the template file is removed.What I did not test:
e2e-aws-ovn-upgradeande2e-gcp-op-single-node.AI use: this change was written and tested with Claude Code.
- Description for the changelog
Nodes turn the cgroup v2 mount option
memory_hugetlb_accountingoff at boot, so that pods that use hugepages keep their current memory accounting when systemd starts to set the option.<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
<!-- coderabbit-ai-generated:v1 -->
Summary by CodeRabbit
Bug Fixes
Machine configurations now ensure that cgroup v2 mounts do not retain the
memory_hugetlb_accountingoption. This setting is handled consistently across configured platforms and machine roles, helping avoid differences in cgroup mount behavior during system startup. The change applies automatically when the option is present; when it is absent, startup proceeds without remounting.<!-- end of auto-generated comment: release notes by coderabbit.ai -->