Skip to content

Added spec.podTemplateSpec support to MCPRemoteProxy - #5531

Merged
aponcedeleonch merged 5 commits into
stacklok:mainfrom
Sanskarzz:addpodtemplate
Jul 15, 2026
Merged

Added spec.podTemplateSpec support to MCPRemoteProxy#5531
aponcedeleonch merged 5 commits into
stacklok:mainfrom
Sanskarzz:addpodtemplate

Conversation

@Sanskarzz

Copy link
Copy Markdown
Contributor

Summary

Add spec.podTemplateSpec support to MCPRemoteProxy so remote proxy workloads can be customized like the other ToolHive workload CRDs.

Although the issue calls out v1alpha1, this branch defines v1alpha1.MCPRemoteProxy.Spec as v1beta1.MCPRemoteProxySpec, so the API field is added to the shared v1beta1 spec. Regenerated CRDs expose the field in both served schema sections.

Fixes #4549

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Dependency update
  • Documentation
  • Other (describe):

Test plan

  • Unit tests (task test)
  • E2E tests (task test-e2e)
  • Linting (task lint-fix)
  • Manual testing (describe below)

API Compatibility

  • This PR does not break the v1beta1 API, OR the api-break-allowed label is applied and the migration guidance is described above.

Changes

  • Added optional spec.podTemplateSpec to MCPRemoteProxySpec using runtime.RawExtension with unknown-field preservation.
  • Added MCPRemoteProxy-specific PodTemplateValid condition type and valid/invalid reasons.
  • Validates PodTemplateSpec early in the MCPRemoteProxy reconcile path and blocks Deployment updates when invalid.
  • Applies valid PodTemplateSpec customizations to the generated Deployment using the existing controllerutil.ApplyPodTemplateSpecPatch strategic merge helper.
  • Tracks raw PodTemplateSpec changes with the shared toolhive.stacklok.io/podtemplatespec-hash annotation.
  • Added focused tests for validation, merge behavior, fields outside the builder emptiness check, and drift detection.
  • Regenerated deepcopy, CRDs, Helm CRD templates, and CRD reference docs.

@github-actions github-actions Bot added the size/M Medium PR: 300-599 lines changed label Jun 15, 2026
@codecov

codecov Bot commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.33333% with 37 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.79%. Comparing base (59d8466) to head (e961b43).

Files with missing lines Patch % Lines
...-operator/controllers/mcpremoteproxy_controller.go 77.95% 15 Missing and 13 partials ⚠️
...-operator/controllers/mcpremoteproxy_deployment.go 60.86% 6 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5531      +/-   ##
==========================================
- Coverage   70.80%   70.79%   -0.01%     
==========================================
  Files         685      685              
  Lines       69460    69592     +132     
==========================================
+ Hits        49181    49269      +88     
- Misses      16682    16714      +32     
- Partials     3597     3609      +12     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Sanskarzz <sanskar.gur@gmail.com>
@github-actions github-actions Bot added size/M Medium PR: 300-599 lines changed and removed size/M Medium PR: 300-599 lines changed labels Jun 15, 2026
@github-actions github-actions Bot added size/M Medium PR: 300-599 lines changed and removed size/M Medium PR: 300-599 lines changed labels Jun 23, 2026
@ChrisJBurns

Copy link
Copy Markdown
Collaborator

@Sanskarzz Thanks for this! Just wanted to add a comment so you don't think we've forgotten, just a bit busy atm. I'll be reviewing it soon enough though! 🚀 😆

@Sanskarzz

Copy link
Copy Markdown
Contributor Author

Thanks @ChrisJBurns , no worries at all. Appreciate the update! I’ll keep an eye out for the review and will address any feedback once you get a chance to look at it.

@aponcedeleonch aponcedeleonch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work. This is the last workload CRD missing podTemplateSpec, so it's a welcome parity fix, and the implementation mirrors the MCPServer reference closely. The logic checks out for me. Two things are blocking it right now, both mechanical:

  • cmd/thv-operator/controllers/mcpremoteproxy_controller.go:398 has a gofmt slip (spaces instead of a tab on a closing brace), which fails the Lint job. A task lint-fix should sort it.
  • mcpremoteproxy_podtemplatespec_test.go references createRunConfigTestScheme, which no longer exists on main. It got renamed to testutil.NewScheme(t). Looks like merge rot, and it breaks the whole controllers test package, so the Test job is red too. Swapping to testutil.NewScheme(t) and adding the internal/testutil import fixes it.

I applied both locally and the new PodTemplateSpec tests plus the full controllers package go green, so once those land I think this is good to merge. One non-blocking nit: the rawPodTemplateSpecJSON helper unmarshals into a throwaway map and then discards it, so that validation is effectively dead code. Up to you.

@github-actions github-actions Bot added size/M Medium PR: 300-599 lines changed and removed size/M Medium PR: 300-599 lines changed labels Jul 14, 2026
Signed-off-by: Sanskarzz <sanskar.gur@gmail.com>
@github-actions github-actions Bot added size/M Medium PR: 300-599 lines changed and removed size/M Medium PR: 300-599 lines changed labels Jul 14, 2026
@Sanskarzz

Copy link
Copy Markdown
Contributor Author

Thanks for the review! Fixed both blocking issues:

  • Ran task lint-fix and corrected the gofmt slip in mcpremoteproxy_controller.go.
  • Replaced the stale createRunConfigTestScheme() usage with testutil.NewScheme(t) in the new PodTemplateSpec tests.
  • Also cleaned up the rawPodTemplateSpecJSON helper by removing the unused throwaway JSON unmarshal.

@github-actions github-actions Bot removed the size/M Medium PR: 300-599 lines changed label Jul 15, 2026
@github-actions github-actions Bot added the size/M Medium PR: 300-599 lines changed label Jul 15, 2026

@aponcedeleonch aponcedeleonch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! thanks

@aponcedeleonch
aponcedeleonch merged commit 52f82ed into stacklok:main Jul 15, 2026
44 of 46 checks passed
@github-actions github-actions Bot mentioned this pull request Jul 15, 2026
2 tasks
JAORMX pushed a commit that referenced this pull request Jul 15, 2026
* Add spec.podTemplateSpec support to MCPRemoteProxy

Signed-off-by: Sanskarzz <sanskar.gur@gmail.com>

* addressed review comments

Signed-off-by: Sanskarzz <sanskar.gur@gmail.com>

---------

Signed-off-by: Sanskarzz <sanskar.gur@gmail.com>
Co-authored-by: Alejandro Ponce de Leon <aponcedeleonch@stacklok.com>
github-actions Bot added a commit to stacklok/docs-website that referenced this pull request Jul 16, 2026
Covers the new spec.podTemplateSpec field added in stacklok/toolhive#5531.
Adds a "Customize the remote proxy pod" section modeled on the parallel
MCPServer pattern (container name toolhive, not mcp) and notes the new
PodTemplateValid condition in the status section.
danbarr pushed a commit to stacklok/docs-website that referenced this pull request Jul 17, 2026
* Update stacklok/toolhive to v0.38.0

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Refresh reference assets for toolhive v0.38.0

* Document podTemplateSpec on MCPRemoteProxy for v0.37.0

Covers the new spec.podTemplateSpec field added in stacklok/toolhive#5531.
Adds a "Customize the remote proxy pod" section modeled on the parallel
MCPServer pattern (container name toolhive, not mcp) and notes the new
PodTemplateValid condition in the status section.

* Fix inaccurate example list in podTemplateSpec section

spec.resources is a first-class field on MCPRemoteProxy, so listing
resource limits among options 'not exposed as first-class fields' is
misleading. Swap for affinity rules, which genuinely require
podTemplateSpec.

---------

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Medium PR: 300-599 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add PodTemplateSpec to MCPRemoteProxy

3 participants