Skip to content

Conversation

@yrobla
Copy link
Contributor

@yrobla yrobla commented Dec 4, 2025

Add proper reconciliation, dynamic updates and overrides support Add tests to validate it

Large PR Justification

This is an atomic PR, that captured some bugs and needs for improvement, and also added relevant tests.

@github-actions github-actions bot added the size/L Large PR: 600-999 lines changed label Dec 4, 2025
@codecov
Copy link

codecov bot commented Dec 4, 2025

Codecov Report

❌ Patch coverage is 97.05882% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.50%. Comparing base (0c0d907) to head (dabba77).

Files with missing lines Patch % Lines
cmd/thv-operator/pkg/vmcpconfig/converter.go 97.05% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2891      +/-   ##
==========================================
+ Coverage   56.36%   56.50%   +0.14%     
==========================================
  Files         323      323              
  Lines       31764    31816      +52     
==========================================
+ Hits        17904    17978      +74     
+ Misses      12331    12308      -23     
- Partials     1529     1530       +1     

☔ View full report in Codecov by Sentry.
📢 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.

@yrobla yrobla force-pushed the feat/add_tool_filter_mcptoolconfig branch from f2fdec4 to 7d4a1db Compare December 4, 2025 10:55
@yrobla yrobla requested review from JAORMX, Copilot and jhrozek December 4, 2025 10:56
@yrobla yrobla force-pushed the feat/add_tool_filter_mcptoolconfig branch from 7d4a1db to d59dd3b Compare December 4, 2025 10:58
@github-actions github-actions bot added size/L Large PR: 600-999 lines changed and removed size/L Large PR: 600-999 lines changed labels Dec 4, 2025
Copilot finished reviewing on behalf of yrobla December 4, 2025 11:03
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds proper MCPToolConfig reconciliation, dynamic updates, and override support for VirtualMCPServer, along with comprehensive e2e tests to validate the functionality.

Key changes:

  • Added MCPToolConfig reference resolution in the VirtualMCPServer converter with proper filter and override merging
  • Implemented watch-based reconciliation to trigger VirtualMCPServer updates when referenced MCPToolConfigs change
  • Added comprehensive e2e tests covering filtering, overrides, and dynamic configuration updates

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/e2e/thv-operator/virtualmcp/virtualmcp_toolconfig_test.go New e2e tests for MCPToolConfig filtering, overrides, and dynamic updates
cmd/thv-operator/pkg/vmcpconfig/converter.go Extended converter to resolve MCPToolConfig references and merge filters/overrides with precedence rules
cmd/thv-operator/pkg/vmcpconfig/converter_test.go Updated test helper to pass required k8sClient parameter to converter
cmd/thv-operator/controllers/virtualmcpserver_vmcpconfig_test.go Updated test to create fake k8s client for converter initialization
cmd/thv-operator/controllers/virtualmcpserver_vmcpconfig.go Updated to pass k8sClient to converter constructor
cmd/thv-operator/controllers/virtualmcpserver_podtemplatespec_reconcile_test.go Updated test calls to include workloadNames parameter
cmd/thv-operator/controllers/virtualmcpserver_controller.go Updated function call to include workloadNames parameter and added MCPToolConfig watch

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions github-actions bot added size/XL Extra large PR: 1000+ lines changed and removed size/L Large PR: 600-999 lines changed labels Dec 4, 2025
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Large PR Detected

This PR exceeds 1000 lines of changes and requires justification before it can be reviewed.

How to unblock this PR:

Add a section to your PR description with the following format:

## Large PR Justification

[Explain why this PR must be large, such as:]
- Generated code that cannot be split
- Large refactoring that must be atomic
- Multiple related changes that would break if separated
- Migration or data transformation

Alternative:

Consider splitting this PR into smaller, focused changes (< 1000 lines each) for easier review and reduced risk.

See our Contributing Guidelines for more details.


This review will be automatically dismissed once you add the justification section.

@yrobla yrobla force-pushed the feat/add_tool_filter_mcptoolconfig branch from 512c37c to eb5430a Compare December 4, 2025 11:18
@github-actions github-actions bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Dec 4, 2025
@yrobla yrobla requested a review from Copilot December 4, 2025 11:20
Copilot finished reviewing on behalf of yrobla December 4, 2025 11:24
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@yrobla yrobla force-pushed the feat/add_tool_filter_mcptoolconfig branch from eb5430a to 8d52325 Compare December 4, 2025 11:34
@github-actions github-actions bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Dec 4, 2025
@github-actions github-actions bot dismissed their stale review December 4, 2025 11:34

Large PR justification has been provided. Thank you!

@github-actions
Copy link
Contributor

github-actions bot commented Dec 4, 2025

✅ Large PR justification has been provided. The size review has been dismissed and this PR can now proceed with normal review.

@yrobla yrobla requested review from amirejaz and rdimitrov December 4, 2025 11:49
Copy link
Contributor

@jhrozek jhrozek left a comment

Choose a reason for hiding this comment

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

PR Review: MCPToolConfig Support for VirtualMCPServer

Overall, this is a solid implementation with excellent test coverage. I have a few observations about error handling patterns and code organization that are worth considering.

Error Handling: Fails Open vs Fails Closed

In applyToolConfigRef (converter.go:337-341), the error handling logs the failure but continues with an empty/incomplete configuration. This is different from how OIDC resolution handles errors (lines 135-138), which fails closed by returning an error.

Concern: If a user explicitly references an MCPToolConfig that doesn't exist (typo, not yet created, deleted), the VirtualMCPServer will deploy with no tool filtering applied instead of failing. This could be a security concern if tool filtering was intended to restrict exposed tools.

Question: Was this intentional to allow graceful degradation, or should this fail closed like OIDC resolution to ensure explicit configuration errors are caught?

// OIDC resolution (fails closed):
return nil, fmt.Errorf("OIDC resolution failed for type %q: %w", ...)

// MCPToolConfig resolution (fails open):
ctxLogger.Error(err, "failed to resolve MCPToolConfig reference", ...)
return  // continues without config

Unreachable Code (converter.go:344-346)

The nil check if resolvedConfig == nil appears unreachable. Looking at resolveMCPToolConfig (lines 407-421), it either returns (toolConfig, nil) on success or (nil, error) on failure - it never returns (nil, nil).

If this is intentional defensive coding, consider adding a comment explaining the reasoning.

Minor: Method Receiver Pattern (converter.go:353, 363, 386)

The methods mergeToolConfigFilter, mergeToolConfigOverrides, and applyInlineOverrides use (*Converter) receiver but don't access any Converter fields - they're pure functions operating only on their parameters.

Question: Would it be cleaner to make these package-level functions, or use a value receiver (Converter) to signal they're stateless? This is a minor stylistic point.


Summary:

  • 3 observations/questions noted
  • No blocking issues identified
  • Test coverage is comprehensive

Copy link
Contributor

@jhrozek jhrozek left a comment

Choose a reason for hiding this comment

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

PR Review: MCPToolConfig Support for VirtualMCPServer

Overall, this is a solid implementation with excellent test coverage. I have a few observations about error handling patterns and code organization that are worth considering.

Error Handling: Fails Open vs Fails Closed

In applyToolConfigRef (converter.go:337-341), the error handling logs the failure but continues with an empty/incomplete configuration. This is different from how OIDC resolution handles errors (lines 135-138), which fails closed by returning an error.

Concern: If a user explicitly references an MCPToolConfig that doesn't exist (typo, not yet created, deleted), the VirtualMCPServer will deploy with no tool filtering applied instead of failing. This could be a security concern if tool filtering was intended to restrict exposed tools.

Question: Was this intentional to allow graceful degradation, or should this fail closed like OIDC resolution to ensure explicit configuration errors are caught?

// OIDC resolution (fails closed):
return nil, fmt.Errorf("OIDC resolution failed for type %q: %w", ...)

// MCPToolConfig resolution (fails open):
ctxLogger.Error(err, "failed to resolve MCPToolConfig reference", ...)
return  // continues without config

Unreachable Code (converter.go:344-346)

The nil check if resolvedConfig == nil appears unreachable. Looking at resolveMCPToolConfig (lines 407-421), it either returns (toolConfig, nil) on success or (nil, error) on failure - it never returns (nil, nil).

If this is intentional defensive coding, consider adding a comment explaining the reasoning.

Minor: Method Receiver Pattern (converter.go:353, 363, 386)

The methods mergeToolConfigFilter, mergeToolConfigOverrides, and applyInlineOverrides use (*Converter) receiver but don't access any Converter fields - they're pure functions operating only on their parameters.

Question: Would it be cleaner to make these package-level functions, or use a value receiver (Converter) to signal they're stateless? This is a minor stylistic point.


Summary:

  • 3 observations/questions noted
  • No blocking issues identified
  • Test coverage is comprehensive

@github-actions github-actions bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Dec 5, 2025
@yrobla yrobla force-pushed the feat/add_tool_filter_mcptoolconfig branch from b7eb620 to ddb20ce Compare December 5, 2025 09:45
@github-actions github-actions bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Dec 5, 2025
Add proper reconciliation, dynamic updates and overrides support
Add tests to validate it
@yrobla yrobla force-pushed the feat/add_tool_filter_mcptoolconfig branch from ddb20ce to 3a788d4 Compare December 5, 2025 11:49
@github-actions github-actions bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Dec 5, 2025
@yrobla yrobla force-pushed the feat/add_tool_filter_mcptoolconfig branch from 3a788d4 to 5473c52 Compare December 5, 2025 11:54
@github-actions github-actions bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Dec 5, 2025
@yrobla yrobla force-pushed the feat/add_tool_filter_mcptoolconfig branch from 5473c52 to d644395 Compare December 5, 2025 11:58
@yrobla yrobla requested review from Copilot and jhrozek December 5, 2025 11:58
@github-actions github-actions bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Dec 5, 2025
Copilot finished reviewing on behalf of yrobla December 5, 2025 12:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions github-actions bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Dec 5, 2025
@yrobla
Copy link
Contributor Author

yrobla commented Dec 5, 2025

PR Review: MCPToolConfig Support for VirtualMCPServer

Overall, this is a solid implementation with excellent test coverage. I have a few observations about error handling patterns and code organization that are worth considering.

Error Handling: Fails Open vs Fails Closed

In applyToolConfigRef (converter.go:337-341), the error handling logs the failure but continues with an empty/incomplete configuration. This is different from how OIDC resolution handles errors (lines 135-138), which fails closed by returning an error.

Concern: If a user explicitly references an MCPToolConfig that doesn't exist (typo, not yet created, deleted), the VirtualMCPServer will deploy with no tool filtering applied instead of failing. This could be a security concern if tool filtering was intended to restrict exposed tools.

Question: Was this intentional to allow graceful degradation, or should this fail closed like OIDC resolution to ensure explicit configuration errors are caught?

// OIDC resolution (fails closed):
return nil, fmt.Errorf("OIDC resolution failed for type %q: %w", ...)

// MCPToolConfig resolution (fails open):
ctxLogger.Error(err, "failed to resolve MCPToolConfig reference", ...)
return  // continues without config

Unreachable Code (converter.go:344-346)

The nil check if resolvedConfig == nil appears unreachable. Looking at resolveMCPToolConfig (lines 407-421), it either returns (toolConfig, nil) on success or (nil, error) on failure - it never returns (nil, nil).

If this is intentional defensive coding, consider adding a comment explaining the reasoning.

Minor: Method Receiver Pattern (converter.go:353, 363, 386)

The methods mergeToolConfigFilter, mergeToolConfigOverrides, and applyInlineOverrides use (*Converter) receiver but don't access any Converter fields - they're pure functions operating only on their parameters.

Question: Would it be cleaner to make these package-level functions, or use a value receiver (Converter) to signal they're stateless? This is a minor stylistic point.

Summary:

  • 3 observations/questions noted
  • No blocking issues identified
  • Test coverage is comprehensive

please review again

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

Labels

size/XL Extra large PR: 1000+ lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants