Skip to content

Clamp VirtualMCPServer resource defaults against podTemplateSpec #7154

Open

Description

@ChrisJBurns

Problem

VirtualMCPServer sets default resources on the vmcp container in virtualmcpserver_deployment.go: requests of 100m CPU / 128Mi memory and limits of 500m CPU / 512Mi memory. It then applies the user's podTemplateSpec on top as a strategic merge patch.

A strategic merge patch merges requests and limits key by key. So a podTemplateSpec that sets only one side keeps the other side's defaults, and the request can end up above the limit:

spec:
  podTemplateSpec:
    spec:
      containers:
        - name: vmcp
          resources:
            requests:
              memory: 1Gi

This yields requests.memory: 1Gi with the default limits.memory: 512Mi. The apiserver rejects that Deployment, and reconcile keeps retrying. The reverse also fails: a limits.cpu below the default 100m request is rejected too.

We found this while reviewing #7137, which hit the same problem for MCPRemoteProxy. The vMCP case follows the same code path but hasn't been reproduced yet.

Proposed fix

#7137 adds controllerutil.BuildContainerResourceRequirements(defaults, specResources, podTemplateSpec, containerName). It layers the defaults, the CRD resources field and the podTemplateSpec container resources, clamps any defaulted value that would conflict with a user value, and honours null deletions. vMCP can switch to it:

  • Pass the vMCP defaults, an empty mcpv1beta1.ResourceRequirements{} (vMCP has no spec.resources field) and container name vmcp.
  • Keep the existing podTemplateSpec patch step as it is.
  • Add a test that runs a podTemplateSpec resource override through the vMCP deployment builder.

Related cleanup (optional, same or separate PR)

MCPServer (in deploymentForMCPServer and resourceRequirementsForMCPServer) and EmbeddingServer (in applyResourceRequirements) each repeat the conversion that controllerutil.BuildResourceRequirements already does. Neither applies defaults, so switching them over should change no behaviour. One thing to check: EmbeddingServer sets an empty map for the side that isn't set, so confirm its drift detection still treats that as equal.

Depends on #7137.

Activity

  1. pcbeingused333 commented on Nov 18, 2026

    @pcbeingused333
    Contributor

    I'd like to take this one. The plan is the fix proposed above: build the vMCP container resources with controllerutil.BuildContainerResourceRequirements (added in #7137) in virtualmcpserver_deployment.go, so user-provided requests/limits are merged with the defaults without ending up with requests > limits, plus a test for the memory-request-only and low-CPU-limit cases. Could you assign it to me?

    This comment was drafted with AI assistance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageIssue needs initial triage by a maintainer

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions