fix(control-plane): set gateway resources via Helm values, configurable with GATEWAY_RESOURCES - #380
Conversation
… values Since the gateway moved to the upstream OpenShell Helm chart (openshift-online#194), the control plane no longer sets the gateway container's resources, and the chart default is `resources: {}`. Gateways therefore run BestEffort with no memory request or limit. Pass explicit resources in the chart values: requests cpu 100m / memory 512Mi, limits cpu 500m / memory 1Gi. The memory values carry forward the increase proposed in openshift-online#282 after the gateway was OOMKilled at the old 512Mi limit. Update the gateway and Helm-adoption specs to match. Supersedes openshift-online#282. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository YAML (base), Central YAML (inherited) Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
…RESOURCES Let operators size gateway containers per cluster without rebuilding the control-plane image. GATEWAY_RESOURCES takes a JSON Kubernetes ResourceRequirements object and is passed through as the chart's `resources` value. When unset, the built-in defaults apply (requests 100m/512Mi, limits 500m/1Gi). The value replaces the defaults rather than merging with them. It must set limits.memory, no request may exceed its limit, and resource claims are rejected. An invalid value fails controller startup instead of silently falling back, so a typo in a cluster overlay cannot leave gateways under-provisioned without any signal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Amber reviewStatus: Complete |
Set GATEWAY_RESOURCES in deploy/kind so gateways reserve 50m CPU / 128Mi memory instead of the production default of 100m / 512Mi. More gateways then fit on the single Kind node. Limits stay at the defaults (500m / 1Gi) so local runs don't OOMKill. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Verdict
This PR gives the gateway container an explicit resources block (fixing the BestEffort/no-memory-limit regression from the Helm-chart adoption) and makes it operator-tunable via GATEWAY_RESOURCES; the new head also adds a Kind overlay that lowers requests so more gateways fit on the single dev node. The implementation, validation, tests, and spec updates are clean; my only open item is the previously raised supervisor-sidecar scope question plus a cross-PR decision on a duplicate memory-sizing PR.
What works well
ParseGatewayResourcesis strict in the right ways:DisallowUnknownFields, trailing-data rejection,claimsrejection, mandatorylimits.memory, non-negative requests, request-not-exceeding-limit, and positive limits. Each branch is covered by a table test (internal/helm/values_test.goTestParseGatewayResources).- Fail-fast on an invalid
GATEWAY_RESOURCES(abort startup rather than silently reverting to defaults) is the correct call for a sizing control and is justified in the code comment (internal/config/config.goL147-156). Errors are wrapped withfmt.Errorf("...: %w", err)throughout. resourcesis set unconditionally inbuildCoreValues(internal/helm/values.goL133-139), so even the unset path stops the gateway from running BestEffort.TestBuild_GatewayResourceslocks in the default and override behavior;TestLoadGatewayResourcescovers unset/valid/invalid. Nopanic(), no secret exposure, config kept separate from code, and the spec/provenance/env-var tables are updated consistently.- The new Kind overlay change (
deploy/kind/kustomization.yamlL48-53) setsGATEWAY_RESOURCESto50m/128Mirequests with the default500m/1Gilimits. This is a valid override (requests <= limits), the inline comment explains the rationale, and the env-var spec row documents the overlay behavior.
Cross-PR coordination
A separate open PR pursues the same goal - raising the gateway memory request/limit to 512Mi/1Gi - but does so by editing components/control-plane/manifests/gateway/deployment.yaml, a file that no longer exists on main (gateways now deploy via the Helm chart), and it edits the same "Resource requests/limits" bullets in specs/platform/openshell-gateway.spec.md that this PR restructures. That is PR #282. It is a duplicate solution built on the pre-Helm architecture and currently conflicts on the shared spec section, so a maintainer needs to decide to close #282 (or otherwise sequence it) in favor of this PR to avoid two competing memory-sizing changes and conflicting spec edits.
Previous concerns
- Supervisor sidecar may remain BestEffort - still present.
buildCoreValuessets onlysupervisor.image.{repository,tag}(internal/helm/values.goL123-127) and never asupervisor.resourcesvalue; the newresourceskey applies to the gateway container. If the supervisor shares the gateway pod, that container stays without a memory limit even after this fix. This remains a Minor scope question; see the existing inline discussion rather than a new comment. (Confidence: Medium - verified the values builder sets no supervisor resources; did not confirm the chart's supervisor default.) - The prior cross-PR coordination item on the duplicate memory-sizing PR is still present and is carried forward in the Cross-PR coordination section above.
Findings Summary (ordered by severity, highest first):
- [Minor] Supervisor sidecar container may remain BestEffort; only the gateway container gets a
resourcesblock - Container Resources (internal/helm/values.goL123-139) - already tracked in an existing inline thread
Convention Checklist:
| Convention | Result |
|---|---|
No panic() in production code |
Pass |
Errors wrapped with fmt.Errorf context |
Pass |
| No secrets in logs or responses | Pass |
Input validated (GATEWAY_RESOURCES JSON) |
Pass |
| Config separate from code | Pass |
| Test diff scrutiny (only additive tests) | Pass |
| Spec/docs updated consistently | Pass |
| Conventional commit message | Pass |

Supersedes #282.
#282 raised the gateway memory in
components/control-plane/manifests/gateway/deployment.yaml. That manifest was removed in #194 when gateways moved to the upstream OpenShell Helm chart. Since then the control plane has not set the gateway container's resources, and the chart default isresources: {}(deploy/helm/openshell/values.yamlatv0.0.116-rhaiv.6). Gateways now run BestEffort: no memory limit, nothing reserved at scheduling, and they are among the first pods evicted under node memory pressure.This PR:
resourcesvalue ininternal/helm/values.go. The defaults are requestscpu: 100m,memory: 512Miand limitscpu: 500m,memory: 1Gi, the memory sizing proposed in fix(control-plane): increase gateway memory capacity #282 after the OOMKill at 512Mi.GATEWAY_RESOURCES, an optional controller env var holding a JSON KubernetesResourceRequirementsobject. It lets each cluster size its gateways from its gitops overlay without rebuilding the image:{"requests":{"cpu":"100m","memory":"512Mi"},"limits":{"cpu":"500m","memory":"1Gi"}}limits.memory, no request may exceed its limit, andclaimsis rejected. An invalid value fails controller startup instead of falling back to the defaults, so a typo cannot leave gateways under-sized with no signal. This deliberately differs fromGATEWAY_RECONCILE_WORKERSand the other tunables.config.Load→NewGatewayReconciler→ReconcileOpts.GatewayResources→ValuesBuilder.Resources.GATEWAY_RESOURCESin the Kind overlay (deploy/kind) to lower requests (cpu: 50m,memory: 128Mi) with the default limits, so more gateways fit on the single Kind node. OpenShift and IBM overlays keep the defaults.openshell-gateway.spec.md(Deployment resources, env var table, Helm provenance table) andopenshell-gateway-helm-adoption.spec.md(Core Values table).The chart renders
.Values.resourcesdirectly into the gateway container (_gateway-workload.tpl). The reconciler runshelm upgradeon already-deployed releases, so after the control-plane image rolls out, or afterGATEWAY_RESOURCESchanges, existing gateways pick up the new resources on their next reconcile. That upgrade restarts the gateway pods.Validation:
make checkgo build ./..., andgo vet/go testforinternal/helm,internal/config,internal/gateway,internal/reconcilerincomponents/control-planeTestBuild_GatewayResources(default and override),TestParseGatewayResources(accept and reject cases),TestLoadGatewayResources(unset, valid, invalid fails startup)As #282 noted, the 1Gi limit adds headroom; it does not establish the cause of memory growth. Peak gateway memory should still be measured during review cycles.
🤖 Generated with Claude Code