Restructure MCPTelemetryConfig CRD to nested spec per RFC THV-0023#4487
Restructure MCPTelemetryConfig CRD to nested spec per RFC THV-0023#4487ChrisJBurns merged 7 commits intomainfrom
Conversation
There was a problem hiding this comment.
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 transformationAlternative:
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.
|
@claude review this PR focusing only on critical and high severity issues. Ignore medium/low severity, style preferences, and controversial opinions. Focus on:
|
|
Claude finished @ChrisJBurns's task in 4m 10s —— View job PR Review: Restructure MCPTelemetryConfig CRD
Found 3 high-severity issues. No critical security issues. HIGH —
|
|
✅ Large PR justification has been provided. The size review has been dismissed and this PR can now proceed with normal review. |
Large PR justification has been provided. Thank you!
|
@claude re-review this PR. The two high-severity issues from your previous review have been addressed:
Both have new test cases. Please verify the fixes and flag any remaining critical/high issues only. |
|
Claude finished @ChrisJBurns's task in 1m 55s —— View job PR Re-review: Restructure MCPTelemetryConfig CRD
Both previously-flagged high-severity fixes are confirmed. No new critical or high issues found. Fix #1 VERIFIED —
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4487 +/- ##
=======================================
Coverage 69.34% 69.35%
=======================================
Files 502 502
Lines 51643 51683 +40
=======================================
+ Hits 35814 35843 +29
- Misses 13063 13069 +6
- Partials 2766 2771 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
41bd22c to
e863bd1
Compare
|
Summary of offline discussion Jeremy and I discussed this concern in depth offline. Here's the conclusion we arrived at: Why we're keeping separate types (CRD types vs. runtime config types):
What we agreed to improve going forward: We acknowledged that the duplication and manual conversion layers are a real maintenance burden and error-prone. We agreed on this direction:
TL;DR: Merging this PR as-is. The separate types are intentional for safety, and we'll address the maintainability concerns through automated drift detection and a broader RFC. |
The MCPTelemetryConfig spec was using a flat inline embedding of telemetry.Config which exposed CLI-only fields and didn't match the nested structure specified in RFC THV-0023. Restructure to use openTelemetry/prometheus sub-objects: - spec.openTelemetry: endpoint, headers, sensitiveHeaders, resourceAttributes, tracing, metrics, useLegacyAttributes - spec.prometheus: enabled - status.referencingWorkloads: structured WorkloadReference (kind/namespace/name) replacing bare string list Update the conversion layer (spectoconfig, controllerutil) to map the nested CRD types to the flat telemetry.Config at runtime. Add operator example YAML files for MCPTelemetryConfig and MCPServer with telemetryConfigRef. Closes #4262 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Combine MCPTelemetryConfig and MCPServer-with-ref examples into mcpserver_fetch_otel.yaml as a single apply-able file. Remove the separate telemetry-configs directory. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Fix two issues from PR review: - NormalizeMCPTelemetryConfig now gates OTel config on Enabled flag, matching ConvertTelemetryConfig behavior. Setting enabled: false correctly disables OTLP even if sub-fields are populated. - Add CEL validation rejecting endpoint when neither tracing nor metrics is enabled, catching the misconfiguration at admission time instead of failing at proxy runner startup. Add test cases covering both scenarios. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use single-quoted YAML for the endpoint validation CEL rule to match the quoting style of other CEL rules in the chart. Double-quoted YAML caused the rule value to include literal quote characters, failing CRD installation with a CEL syntax error. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The gci linter was replacing ASCII quotes with Unicode smart quotes (U+201C/U+201D) in kubebuilder annotations, breaking controller-gen CRD generation. Additionally, the CEL rule for endpoint validation generated double-quoted YAML that the Helm wrapper mishandled. Move the endpoint-requires-signals validation from a CEL rule to the programmatic Validate() method, which avoids both issues and provides clearer error messages. Add test case for this validation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove duplicate WorkloadReference definition from mcptelemetryconfig_types.go and use the shared type already defined in mcpoidcconfig_types.go. Drop the Namespace field (cross-namespace refs are not supported) to match the shared type's schema. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
e863bd1 to
92f1e78
Compare
jerm-dro
left a comment
There was a problem hiding this comment.
Approving — the nested types approach is well-implemented and the conversion layer is clean and well-tested.
For context: the broader concern around diverging config/CRD types and the cognitive load of maintaining separate type hierarchies will be addressed systemically in toolhive-rfcs#65.
Summary
telemetry.Configwhich exposed CLI-only fields (environmentVariables) and didn't match the nestedopenTelemetry/prometheusstructure specified in RFC THV-0023spec.openTelemetryandspec.prometheussub-objects, addresourceAttributes(replacingcustomAttributes), movesensitiveHeadersunderopenTelemetry, and replacereferencingServers []stringwith structuredreferencingWorkloads []WorkloadReferencetelemetry.Configat runtimeCloses #4262
Type of change
Test plan
task test)task lint-fix)Changes
api/v1alpha1/mcptelemetryconfig_types.gotelemetry.Configinline embed with nestedMCPTelemetryOTelConfig/PrometheusConfig. AddWorkloadReferencetype. Update validation, CEL rules, printcolumnsapi/v1alpha1/zz_generated.deepcopy.gocontrollers/mcptelemetryconfig_controller.gofindReferencingServers→findReferencingWorkloadsreturning[]WorkloadReference. ExtractworkloadRefsEqualhelper to fix cyclomatic complexitypkg/spectoconfig/telemetry.goNormalizeMCPTelemetryConfigfrom one-linerconfig := spec.Configto field-by-field mapping from nested CRD to flattelemetry.Configpkg/controllerutil/telemetry.goSpec.OpenTelemetry.SensitiveHeadersdeploy/charts/operator-crds/examples/operator/telemetry-configs/Does this introduce a user-facing change?
Yes — this is a breaking change to the
MCPTelemetryConfigCRD spec structure. Since the API isv1alpha1(explicitly unstable), breaking changes are expected. Users must update their MCPTelemetryConfig manifests from the flat structure to the nested structure. See the examples inexamples/operator/telemetry-configs/for the new format.Large PR Justification
Generated with Claude Code