[release-4.22] CNTRLPLANE-3526: Add spec.monitoring API for metrics forwarding#8872
[release-4.22] CNTRLPLANE-3526: Add spec.monitoring API for metrics forwarding#8872muraee wants to merge 6 commits into
Conversation
Add MonitoringSpec and MetricsForwardingSpec types to HostedCluster and HostedControlPlane specs, replacing the annotation-based EnableMetricsForwarding mechanism with a proper API field. The new API adds: - monitoring.metricsForwarding.mode (Forward/None) to control metrics forwarding per cluster - monitoring.metricsSet (Telemetry/SRE/All) to override the global METRICS_SET environment variable per cluster Signed-off-by: Mulham Raee <mulham.raee@gmail.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Generated by: make update Signed-off-by: Mulham Raee <mulham.raee@gmail.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Update all consumers to check the new spec field: - HC controller copies Monitoring from HC to HCP with backward compat for the deprecated EnableMetricsForwarding annotation (only when mode is unset; explicit Disabled takes precedence) - CPO resolves per-cluster MetricsSet override before SRE config loading and passes it through ControlPlaneContext - metrics-proxy and endpoint-resolver predicates check Mode enum - HCCO reconcileMetricsForwarder checks spec instead of annotation - HO SRE ConfigMap sync supports per-cluster MetricsSet=SRE (cherry picked from commit ea1eb17) (backport: excluded test/e2e/ changes, resolved conflicts for release-4.22) Signed-off-by: Mulham Raee <mulham.raee@gmail.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Allow the forwarded metrics set (guest-side, via metrics-proxy) to be configured independently from the MC-side ServiceMonitor/PodMonitor relabel configs. When MetricsForwardingSpec.MetricsSet is not set, it falls back to MonitoringSpec.MetricsSet (then to the global METRICS_SET env var). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Broaden SRE ConfigMap watch to enqueue HostedClusters with per-cluster metricsSet SRE override, not just when operator global is SRE - Extract effectiveMetricsSet() helper to deduplicate override resolution - Fix comment to say "None" instead of "Disabled" matching the enum - Fix test names to use Forward/None instead of Enabled/Disabled - Add positive test for Mode=Forward verifying resources are preserved - Add envtest for required mode field on MetricsForwardingSpec - Add godoc to exported Predicate function - Add TestMetricsSetConstantsInSync asserting hyperv1/metrics type parity Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Older CPOs (4.22) only read the EnableMetricsForwarding annotation, not the new spec.monitoring.metricsForwarding field. When the HO sets the spec on the HCP without also setting the annotation, a 4.22 CPO never deploys metrics forwarding components, breaking 4.22 e2e tests and real-world N-1 version skew scenarios. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Pipeline controller notification For optional jobs, comment This repository is configured in: LGTM mode |
|
@muraee: This pull request references CNTRLPLANE-3526 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
@muraee: GitHub didn't allow me to request PR reviews from the following users: openshift/hypershift-team. Note that only openshift members and repo collaborators can review this PR, and authors cannot review their own PRs. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository YAML (base), Central YAML (inherited) Review profile: CHILL Plan: Enterprise Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: muraee The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
@muraee: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## release-4.22 #8872 +/- ##
================================================
+ Coverage 35.78% 35.83% +0.05%
================================================
Files 774 774
Lines 94734 94755 +21
================================================
+ Hits 33904 33960 +56
+ Misses 58065 58025 -40
- Partials 2765 2770 +5
🚀 New features to boost your workflow:
|
|
/lgtm |
|
@muraee: you cannot LGTM your own PR. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Summary
Manual backport of #8626 to
release-4.22. The automated cherry-pick failed due to conflicts from the reconciliation loop restructuring onmain.Changes backported:
spec.monitoring.metricsForwardingAPI on HostedCluster and HostedControlPlane, replacing the annotation-basedhypershift.openshift.io/enable-metrics-forwardingmechanismmetricsSetfield (Telemetry/SRE/All) that overrides the globalMETRICS_SETenv var on the HyperShift OperatorExcluded from backport:
test/e2e/changes (not needed for release-4.22)Conflict resolution:
hostedcluster_controller.go: Applied monitoring changes to the pre-refactor reconciliation flow (release-4.22 uses the linear flow, not the phase-basedreport.executeflow frommain)resources.go: Usedutil.DeleteAllIfNeeded(release-4.22 import) instead ofk8sutil.DeleteAllIfNeeded(main)reconcile_legacy.go: Skipped (file doesn't exist in release-4.22)hostedcluster_controller_test.go: Applied monitoring test additions manually to match release-4.22 imports and structureTest plan
go build ./hypershift-operator/controllers/hostedcluster/...compilesgo build ./control-plane-operator/...compilesTestReconcileMetricsForwarderpassesTestPredicate(endpoint_resolver) passes/cc @openshift/hypershift-team