Repository navigation
Add default resource limits for MCPRemoteProxy - #7137
Merged
Merged
Conversation
Apply proxy-runner defaults when MCPRemoteProxy omits resource requests/limits, merge user overrides on top of those defaults, and keep deployment drift detection aligned with the same effective resource calculation. Closes #3131
Address review feedback on the default resource limits change: - Clamp the defaulted side of a request/limit pair so a partial override (e.g. only requests.memory: 512Mi) cannot produce a request above the default limit, which the apiserver rejects. - Compare resources with equality.Semantic.DeepEqual in drift detection so non-canonical overrides such as cpu "0.2" do not trigger a perpetual reconcile/update loop. - Document the defaults on the CRD field and in the operator architecture doc, and regenerate CRD manifests and API docs. - Fix gofmt and codespell failures. Co-Authored-By: xing <echoecho_2024@qq.com> Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2 of 5 tasks
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #7137 +/- ##
==========================================
- Coverage 81.44% 81.40% -0.04%
==========================================
Files 890 890
Lines 90622 90701 +79
==========================================
+ Hits 73803 73839 +36
- Misses 16814 16857 +43
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The podTemplateSpec is applied as a strategic merge patch after the defaults are set, and that patch merges requests and limits key by key. A podTemplateSpec that set only requests kept the default limits, so the request could exceed the limit and the apiserver rejected the Deployment. On main the same CR was valid because there were no defaults to collide with. Add a generic controllerutil.BuildContainerResourceRequirements that layers defaults, the CRD resources field and the podTemplateSpec container resources (podTemplateSpec wins), then clamps. A null entry in the podTemplateSpec drops that key, matching what the patch does. Defaults are passed in so VirtualMCPServer can adopt it later. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
aponcedeleonch
previously approved these changes
Nov 16, 2026
When a container sets a limit without a request, Kubernetes copies the limit into the request at Pod creation. Filling that gap with our default request instead silently turned a limits-only proxy from Guaranteed into Burstable QoS and shrank its reservation (for example from 2Gi to 64Mi) on upgrade. Drop the default request whenever the user sets a limit without one, in spec.resources or podTemplateSpec. That leaves raising a defaulted limit to meet a user's request as the only remaining adjustment. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
aponcedeleonch
approved these changes
Nov 16, 2026
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
MCPRemoteProxyhas no default resource requests or limits, so a proxy whose CR omitsspec.resourcesruns unbounded. That is the same operational and security gap #2873 closed forVirtualMCPServer. This picks up #5998 by @clxstart (their commit is preserved) and addresses the open review feedback on it.50mCPU /64Mimemory, limits200mCPU /256Mimemory) to any field left unset inspec.resources, with user values overriding per field.toolhivecontainer inpodTemplateSpecoverspec.resources(podTemplateSpecwins) before the strategic merge patch runs. Without this, apodTemplateSpecthat set only requests kept the default limits, and the apiserver rejected the Deployment.request > limit. For example,requests.memory: 512Mion its own now yields a 512Mi limit rather than the 256Mi default, which the apiserver would reject. AnullinpodTemplateSpecremoves the default instead. If a user sets both sides inconsistently, their values are passed through unchanged.equality.Semantic.DeepEqual, the same checkMCPServeruses for container resources. Withreflect.DeepEqual, a non-canonical override such ascpu: "0.2"(stored by the apiserver as200m) reported drift on every reconcile and caused an endless update loop.Fixes #3131
Supersedes #5998
Type of change
Test plan
task operator-test)gofmt,go vet, andcodespellon the changed files.task lint-fixpanics locally inside staticcheck under go1.27 (a toolchain issue that exists onmain, unrelated to this change), so CI's lint job is the authoritative check.New tests cover default injection, per-field merge, limit raising, dropping the default request for limits-only overrides, pass-through of inconsistent user values, no aliasing of inputs, a drift check against apiserver-canonicalized quantities, and resource overrides set through
podTemplateSpec. I confirmed that the drift test fails when the comparison is reverted toreflect.DeepEqual, and that thepodTemplateSpecoverride tests fail without thepodTemplateSpecinput.API Compatibility
v1beta1API, OR theapi-break-allowedlabel is applied and the migration guidance is described above.Only the description of
spec.resourceschanges; the schema itself is unchanged.Does this introduce a user-facing change?
Yes.
MCPRemoteProxywithoutspec.resourcesgot a proxy container with no CPU or memory requests or limits.50mCPU /64Mimemory and limits of200mCPU /256Mimemory. Explicit values still win per field, whether they're set inspec.resourcesor inpodTemplateSpec. A proxy that sets only limits behaves exactly as before: its requests still equal its limits, so its QoS class and reservation don't change.Upgrade impact: every existing
MCPRemoteProxythat leaves any resource field unset rolls once after the operator upgrade and picks up these defaults, including a 256Mi memory limit it didn't have before. A proxy whose working set is above 256Mi (for example, a busy proxy with an embedded auth server) will be OOMKilled after the upgrade. Before upgrading, operators should check memory usage on heavy proxies and setspec.resources.limits.memoryexplicitly where needed.Special notes for reviewers
100m/500m,128Mi/512Mi). That fits a single-upstream HTTP proxy, but it's the main thing to sanity-check given the upgrade impact above.MCPServerstill applies no resource defaults. Bringing it in line would roll everyMCPServerdeployment on upgrade, so that change is left out of this PR.VirtualMCPServerhard-codes its own defaults and has the samepodTemplateSpecgap. That fix is tracked in Clamp VirtualMCPServer resource defaults against podTemplateSpec #7154 and will use the generic helper added here.ResourceRequirementstype to reject arequest > limitthat the user sets explicitly. That rule would also affectMCPServer, so it isn't in this PR.🤖 Generated with Claude Code