Skip to content

Add MCPOIDCConfig controller for lifecycle management#4462

Open
ChrisJBurns wants to merge 8 commits intomainfrom
cburns/mcpoidcconfig-controller-4248
Open

Add MCPOIDCConfig controller for lifecycle management#4462
ChrisJBurns wants to merge 8 commits intomainfrom
cburns/mcpoidcconfig-controller-4248

Conversation

@ChrisJBurns
Copy link
Copy Markdown
Collaborator

@ChrisJBurns ChrisJBurns commented Mar 31, 2026

Summary

  • Adds the controller that reconciles MCPOIDCConfig resources, managing the core CRD lifecycle: adds a finalizer on first reconciliation, validates the spec and sets a Valid condition, and computes a config hash for change detection stored in status.
  • Registers the controller in the operator's manager startup alongside the existing controllers.
  • Generated RBAC ClusterRole updated with permissions for mcpoidcconfigs resources.
  • Includes unit tests and integration tests covering the controller's lifecycle management.
  • Reference tracking, cascade to workloads, and deletion protection are deferred to Workload CRD Config Reference Updates #4253 when workload CRDs gain OIDCConfigRef fields.

Ref #4248

Type of change

  • New feature

Test plan

  • Unit tests (task test)
  • Linting (task lint-fix)

Unit tests (6 functions, 15 subtests) cover hash computation, reconciliation lifecycle, deletion handling, config change detection, validation failure conditions, and type validation. Integration tests (3 cases via envtest) cover creation with Valid condition and hash, hash updates on spec changes, and deletion with finalizer removal.

Changes

File Change
cmd/thv-operator/controllers/mcpoidcconfig_controller.go New controller: Reconcile (finalizer, validation, hash), handleDeletion, SetupWithManager
cmd/thv-operator/controllers/mcpoidcconfig_controller_test.go Unit tests for controller lifecycle
cmd/thv-operator/test-integration/mcp-oidc-config/suite_test.go Integration test suite setup (envtest)
cmd/thv-operator/test-integration/mcp-oidc-config/mcpoidcconfig_controller_integration_test.go Integration tests for creation, hash change, deletion
cmd/thv-operator/main.go Register MCPOIDCConfig controller in setupServerControllers()
deploy/charts/operator/templates/clusterrole/role.yaml Generated RBAC for mcpoidcconfigs resources

Large PR Justification

  • mostly unit tests and integration tests

Special notes for reviewers

Generated with Claude Code

ChrisJBurns and others added 3 commits March 31, 2026 15:11
Platform engineers managing multiple MCP servers with the same identity
provider currently must duplicate OIDC configuration across every
MCPServer resource. This introduces the MCPOIDCConfig CRD that allows
defining shared OIDC configuration once.

The CRD supports three configuration variants (kubernetesServiceAccount,
configMapRef, inline) validated via CEL rules with a type discriminator
field following the established MCPExternalAuthConfig pattern. Audience
and scopes are intentionally excluded from the shared config and will be
specified per-server via MCPOIDCConfigReference when workload CRDs add
reference fields (#4253).

Ref #4248

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
A ConfigMap reference inside a dedicated CRD is unnecessary indirection.
The purpose of MCPOIDCConfig is to be the centralized config — pointing
it at a ConfigMap just adds a hop without value. The two remaining
variants (kubernetesServiceAccount and inline) cover all use cases.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds the controller that reconciles MCPOIDCConfig resources. It manages
the core CRD lifecycle: adds a finalizer on first reconciliation,
validates the spec and sets a Valid condition, and computes a config
hash for change detection stored in status.

Reference tracking (referencingServers), cascade to workloads via
annotation, deletion protection, and duplicate audience warnings will
be wired up when workload CRDs gain OIDCConfigRef fields (#4253).

Ref #4248

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions bot added the size/S Small PR: 100-299 lines changed label Mar 31, 2026
Base automatically changed from cburns/mcpoidcconfig-types-4248 to main March 31, 2026 14:39
Unit tests (6 functions, 15 subtests):
- Config hash consistency across both spec variants
- Full reconciliation lifecycle for inline and kubernetesServiceAccount
- Deletion handling (finalizer removal)
- Config change detection and hash update
- Validation failure sets Valid=False condition
- Type validation defense-in-depth (valid and invalid configs)

Integration tests (3 cases via envtest):
- Valid condition and config hash set on creation
- Config hash updates when spec changes
- Deletion succeeds (finalizer removed, object deleted)

Ref #4248

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 31, 2026

Codecov Report

❌ Patch coverage is 62.16216% with 28 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.61%. Comparing base (e69251a) to head (cb2f623).

Files with missing lines Patch % Lines
...v-operator/controllers/mcpoidcconfig_controller.go 66.66% 17 Missing and 6 partials ⚠️
cmd/thv-operator/main.go 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4462      +/-   ##
==========================================
- Coverage   69.64%   69.61%   -0.04%     
==========================================
  Files         491      492       +1     
  Lines       50304    50378      +74     
==========================================
+ Hits        35036    35069      +33     
- Misses      12580    12618      +38     
- Partials     2688     2691       +3     

☔ 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.
@github-actions github-actions bot added size/XL Extra large PR: 1000+ lines changed and removed size/S Small PR: 100-299 lines changed labels Mar 31, 2026
Copy link
Copy Markdown
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.

@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 Mar 31, 2026
@ChrisJBurns ChrisJBurns changed the title Add MCPOIDCConfig controller for lifecycle management Mar 31, 2026
@github-actions github-actions bot added size/L Large PR: 600-999 lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Mar 31, 2026
@github-actions github-actions bot dismissed their stale review March 31, 2026 15:05

PR size has been reduced below the XL threshold. Thank you for splitting this up!

@github-actions
Copy link
Copy Markdown
Contributor

✅ PR size has been reduced below the XL threshold. The size review has been dismissed and this PR can now proceed with normal review. Thank you for splitting this up!

@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 Mar 31, 2026
@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 Mar 31, 2026
Remove redundant Reconcile table-driven test (subset of ConfigChange
test) and add three missing tests:

- ReconcileNotFound: verifies reconciling a deleted resource returns
  no error and does not requeue
- SteadyStateNoOp: verifies a reconcile with no spec changes makes
  no writes (ResourceVersion unchanged)
- ValidationRecovery: verifies condition transitions from Valid=False
  to Valid=True when an invalid config is fixed, covering the
  condition-changed-without-hash-change code path

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@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 Mar 31, 2026
Copy link
Copy Markdown
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.

Add mcpoidcconfigs to the ClusterRole assertions in both single-tenancy
and multi-tenancy chainsaw test suites to match the generated role.yaml.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@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 Mar 31, 2026
@github-actions github-actions bot dismissed their stale review March 31, 2026 18:25

Large PR justification has been provided. Thank you!

@github-actions
Copy link
Copy Markdown
Contributor

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

@ChrisJBurns ChrisJBurns changed the title DRAFT (DONT REVIEW YET) Add MCPOIDCConfig controller for lifecycle management Mar 31, 2026
@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 Mar 31, 2026
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

1 participant