Skip to content

fix: honor MCPServerRegistration targetRef namespace#1139

Draft
avinxshKD wants to merge 1 commit into
Kuadrant:mainfrom
avinxshKD:fix/targetref-namespace
Draft

fix: honor MCPServerRegistration targetRef namespace#1139
avinxshKD wants to merge 1 commit into
Kuadrant:mainfrom
avinxshKD:fix/targetref-namespace

Conversation

@avinxshKD

@avinxshKD avinxshKD commented Jun 14, 2026

Copy link
Copy Markdown

Fixes MCPServerRegistration reconciliation when spec.targetRef.namespace points at an HTTPRoute outside the registration namespace.

The API and docs allow this, and the field index/status update paths already account for it, but getTargetHTTPRoute always read the route from the MCPServerRegistration namespace.

This updates route lookup to use targetRef.namespace when set, with a regression test for cross-namespace refs.

Fixes: #1199

Tested:

  • go test ./internal/controller

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced HTTPRoute target resolution to correctly derive namespace information from target references, with fallback to default namespace when not specified, enabling flexible cross-namespace HTTPRoute configuration.
  • Tests

    • Added test coverage for namespace resolution behavior in HTTPRoute targeting.

Signed-off-by: Avinash Kumar Deepak <avinash8655279@gmail.com>
@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

getTargetHTTPRoute is updated to use mcpsr.Spec.TargetRef.Namespace when non-empty for the HTTPRoute lookup, falling back to mcpsr.Namespace. A new test, TestGetTargetHTTPRouteUsesTargetRefNamespace, validates this cross-namespace path with a fake client.

Changes

Cross-namespace HTTPRoute Lookup

Layer / File(s) Summary
Namespace resolution + test
internal/controller/mcpserverregistration_controller.go, internal/controller/mcpserverregistration_controller_test.go
getTargetHTTPRoute now conditionally reads TargetRef.Namespace before falling back to mcpsr.Namespace; new test builds a fake scheme/client, places an HTTPRoute in the target namespace, and asserts the correct namespace is returned.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

Suggested labels

review-effort/medium

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main fix: enabling MCPServerRegistration to honor the targetRef namespace field for cross-namespace HTTPRoute references.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot added the review-effort/medium Medium review effort (3): few files, moderate logic label Jun 14, 2026
@avinxshKD

Copy link
Copy Markdown
Author

Hey @jasonmadigan fixed a small controller bug where MCPServerRegistration.spec.targetRef.namespace was ignored during HTTPRoute lookup....added a regression test and verified with go test ./internal/controller.

@david-martin david-martin marked this pull request as draft June 17, 2026 11:22
@david-martin david-martin added the triage/needs-issue PR needs a linked issue label Jun 22, 2026
@Aman-Cool

Copy link
Copy Markdown
Contributor

Thanks for this @avinxshKD, it's exactly the getTargetHTTPRoute namespace bug, and the fix looks right: it now honors targetRef.namespace and matches the status-writeback and watch-index paths, so all three finally agree.

I'd actually filed #1199 for this same bug just before David pointed me here.., could you add Fixes: #1199 to the description? (also clears the needs-issue label.)

A few notes while it's still draft, no rush:

And whenever your primary PR merges (and if you've nothing else queued), would be great to bring this out of draft. happy to re-review and help get it over the line 🙂

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

Labels

review-effort/medium Medium review effort (3): few files, moderate logic triage/needs-issue PR needs a linked issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCPServerRegistration: targetRef.namespace is ignored during HTTPRoute resolution

3 participants