Skip to content

CNTRLPLANE-3526: Add spec.monitoring API for metrics forwarding#8626

Open
muraee wants to merge 3 commits into
openshift:mainfrom
muraee:metrics-forwarding-api
Open

CNTRLPLANE-3526: Add spec.monitoring API for metrics forwarding#8626
muraee wants to merge 3 commits into
openshift:mainfrom
muraee:metrics-forwarding-api

Conversation

@muraee

@muraee muraee commented May 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Introduces spec.monitoring.metricsForwarding API on HostedCluster and HostedControlPlane, replacing the annotation-based hypershift.openshift.io/enable-metrics-forwarding mechanism
  • Adds per-cluster metricsSet field (Telemetry/SRE/All) that overrides the global METRICS_SET env var on the HyperShift Operator
  • Updates all consumers (CPO predicates, HCCO, HO SRE config sync) to use the new spec field
  • Maintains backward compatibility: the deprecated annotation is honored when the spec field is not set

Test plan

  • Unit tests pass for endpoint-resolver predicate (TestPredicate)
  • Unit tests pass for HCCO metrics forwarder (TestReconcileMetricsForwarder)
  • make verify passes (0 lint issues)
  • make api-lint-fix passes (0 issues)
  • Envtest validation YAML added for monitoring field enum validation
  • E2E: verify metrics forwarding works with spec.monitoring.metricsForwarding.mode: Enabled
  • E2E: verify backward compat with annotation still works

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added structured monitoring configuration on HostedCluster and HostedControlPlane to configure metrics forwarding (Enabled/Disabled) and to select metrics set (Telemetry, SRE, All). Deprecated metrics-forwarding annotation is preserved for backward compatibility when the spec is unset.
  • Bug Fixes

    • Controllers and components now consistently honor spec-driven monitoring settings for enabling/disabling forwarding and SRE metrics selection.
  • Tests

    • Updated unit and e2e tests and helpers to exercise the new spec-driven monitoring behavior.

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: LGTM mode

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label May 28, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@muraee: This pull request explicitly references no jira issue.

Details

In response to this:

Summary

  • Introduces spec.monitoring.metricsForwarding API on HostedCluster and HostedControlPlane, replacing the annotation-based hypershift.openshift.io/enable-metrics-forwarding mechanism
  • Adds per-cluster metricsSet field (Telemetry/SRE/All) that overrides the global METRICS_SET env var on the HyperShift Operator
  • Updates all consumers (CPO predicates, HCCO, HO SRE config sync) to use the new spec field
  • Maintains backward compatibility: the deprecated annotation is honored when the spec field is not set

Test plan

  • Unit tests pass for endpoint-resolver predicate (TestPredicate)
  • Unit tests pass for HCCO metrics forwarder (TestReconcileMetricsForwarder)
  • make verify passes (0 lint issues)
  • make api-lint-fix passes (0 issues)
  • Envtest validation YAML added for monitoring field enum validation
  • E2E: verify metrics forwarding works with spec.monitoring.metricsForwarding.mode: Enabled
  • E2E: verify backward compat with annotation still works

🤖 Generated with Claude Code

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.

@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 28, 2026
@openshift-ci

openshift-ci Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR migrates metrics forwarding configuration from annotation-based to spec-based control. It adds MonitoringSpec, MetricsForwardingSpec, and enums (MetricsForwardingMode, MetricsSet), copies HostedCluster.Spec.Monitoring to HostedControlPlane.Spec.Monitoring with a backward-compatibility shim for the deprecated annotation, computes an effective metrics set for SRE reconciliation, updates controller predicates and gating to use the spec field, and updates unit and e2e tests to drive behavior via the new spec.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant HostedClusterController
  participant HostedCluster
  participant HostedControlPlane
  participant ControlPlaneOperator
  participant MetricsForwarder

  User->>HostedCluster: set spec.monitoring.metricsForwarding.mode=Enabled
  HostedClusterController->>HostedCluster: read Spec.Monitoring
  HostedClusterController->>HostedControlPlane: copy Spec.Monitoring (apply deprecated-annotation shim if unset)
  ControlPlaneOperator->>HostedControlPlane: read Spec.Monitoring
  ControlPlaneOperator->>MetricsForwarder: enable/disable based on MetricsForwarding.Mode and MetricsSet
  MetricsForwarder-->>ControlPlaneOperator: status
Loading

Suggested reviewers

  • jparrill
  • sdminonne
🚥 Pre-merge checks | ✅ 10 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Test Structure And Quality ⚠️ Warning Unit tests lack meaningful failure messages on assertions: TestPredicate, TestReconcileMetricsForwarder, TestReconcileHostedControlPlaneMonitoring missing diagnostic context. Add descriptive failure messages to Expect() assertions (e.g., Expect(err).NotTo(HaveOccurred(), "should enable metrics forwarding on HCP") to help diagnose failures.
✅ Passed checks (10 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding a new spec.monitoring API field to enable metrics forwarding configuration.
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.
Stable And Deterministic Test Names ✅ Passed All test names are stable and deterministic. No dynamic content found in test case names (no fmt.Sprintf, string concatenation, UUIDs, timestamps, or generated identifiers detected).
Topology-Aware Scheduling Compatibility ✅ Passed PR only adds API schema and controller logic for metrics forwarding; no deployment manifests, affinity rules, topology constraints, or topology-unaware replica logic.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed New e2e tests contain no hardcoded IPv4 addresses, IPv4-specific parsing, or external connectivity requirements. All connections use DNS service names and cluster-internal services.
No-Weak-Crypto ✅ Passed No weak cryptography usage found in PR: no MD5, SHA1, DES, RC4, 3DES, Blowfish, ECB mode, custom crypto implementations, or non-constant-time secret comparisons detected in modified code.
Container-Privileges ✅ Passed PR adds monitoring API fields; no privileged container settings (privileged: true, hostPID, hostNetwork, hostIPC, SYS_ADMIN, allowPrivilegeEscalation: true, runAsUser: 0) introduced.
No-Sensitive-Data-In-Logs ✅ Passed PR adds monitoring API fields (Enabled/Disabled enums and metrics sets) with no logging of spec values; code reads these fields for feature gating but never logs them.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@muraee muraee marked this pull request as ready for review May 28, 2026 14:53
@openshift-ci openshift-ci Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 28, 2026
@muraee muraee changed the title NO-JIRA: Add spec.monitoring API for metrics forwarding CNTRLPLANE-3526: Add spec.monitoring API for metrics forwarding May 28, 2026
@openshift-ci-robot

openshift-ci-robot commented May 28, 2026

Copy link
Copy Markdown

@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 "5.0.0" version, but no target version was set.

Details

In response to this:

Summary

  • Introduces spec.monitoring.metricsForwarding API on HostedCluster and HostedControlPlane, replacing the annotation-based hypershift.openshift.io/enable-metrics-forwarding mechanism
  • Adds per-cluster metricsSet field (Telemetry/SRE/All) that overrides the global METRICS_SET env var on the HyperShift Operator
  • Updates all consumers (CPO predicates, HCCO, HO SRE config sync) to use the new spec field
  • Maintains backward compatibility: the deprecated annotation is honored when the spec field is not set

Test plan

  • Unit tests pass for endpoint-resolver predicate (TestPredicate)
  • Unit tests pass for HCCO metrics forwarder (TestReconcileMetricsForwarder)
  • make verify passes (0 lint issues)
  • make api-lint-fix passes (0 issues)
  • Envtest validation YAML added for monitoring field enum validation
  • E2E: verify metrics forwarding works with spec.monitoring.metricsForwarding.mode: Enabled
  • E2E: verify backward compat with annotation still works

🤖 Generated with Claude Code

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.

@openshift-ci

openshift-ci Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: muraee
Once this PR has been reviewed and has the lgtm label, please assign sjenning for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added area/api Indicates the PR includes changes for the API area/cli Indicates the PR includes changes for CLI area/control-plane-operator Indicates the PR includes changes for the control plane operator - in an OCP release area/documentation Indicates the PR includes changes for documentation area/hypershift-operator Indicates the PR includes changes for the hypershift operator and API - outside an OCP release area/testing Indicates the PR includes changes for e2e testing and removed do-not-merge/needs-area labels May 28, 2026
@openshift-ci openshift-ci Bot requested review from csrwng and jparrill May 28, 2026 14:53
@muraee

muraee commented May 28, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@github-actions github-actions Bot temporarily deployed to docs-preview/pr-8626 May 28, 2026 14:58 Inactive

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@api/hypershift/v1beta1/hosted_controlplane.go`:
- Around line 190-195: The Monitoring field in HostedControlPlane currently has
an inconsistent JSON tag; locate the Monitoring declaration (Monitoring
MonitoringSpec) and replace the tag string that contains both
"omitempty,omitzero" with the single "omitzero" form (i.e.,
json:"monitoring,omitzero") so it matches the style used by HostedClusterSpec
and other fields like AutoNode.

In
`@control-plane-operator/controllers/hostedcontrolplane/hostedcontrolplane_controller.go`:
- Around line 1189-1192: The code reads
hcp.Spec.Monitoring.MetricsForwarding.MetricsSet without nil checks which can
panic; update the logic around effectiveMetricsSet (and keep r.MetricsSet
fallback) to first verify hcp.Spec.Monitoring != nil and
hcp.Spec.Monitoring.MetricsForwarding != nil before accessing MetricsSet, and
only override effectiveMetricsSet when those pointers are non-nil and MetricsSet
is non-empty (preserve existing behavior of using metrics.MetricsSet(...) when
present).

In
`@control-plane-operator/controllers/hostedcontrolplane/v2/endpoint_resolver/component.go`:
- Around line 46-49: The predicate function dereferences
cpContext.HCP.Spec.Monitoring.MetricsForwarding.Mode without nil checks which
can panic when Monitoring or MetricsForwarding are nil; update
predicate(cpContext component.WorkloadContext) to first check cpContext.HCP,
cpContext.HCP.Spec, cpContext.HCP.Spec.Monitoring and
cpContext.HCP.Spec.Monitoring.MetricsForwarding for nil before reading Mode and
combine that guarded check with the existing DisableMonitoringServices
annotation check (hyperv1.DisableMonitoringServices) so the function returns
false (no metrics forwarding) when any of the intermediate structs are nil and
only true when Mode == hyperv1.MetricsForwardingModeEnabled and monitoring is
not disabled.

In
`@control-plane-operator/controllers/hostedcontrolplane/v2/metrics_proxy/component.go`:
- Around line 69-72: The predicate function reads
cpContext.HCP.Spec.Monitoring.MetricsForwarding.Mode without nil guards; add
checks in predicate to ensure cpContext.HCP, cpContext.HCP.Spec, and
cpContext.HCP.Spec.Monitoring are non-nil (and that Monitoring.MetricsForwarding
is present) before accessing Mode, and return false (no reconcile) if any are
nil; keep the existing DisableMonitoringServices annotation check
(hyperv1.DisableMonitoringServices) and only evaluate Mode when the monitoring
structs exist to avoid nil-pointer panics.

In `@hypershift-operator/controllers/hostedcluster/hostedcluster_controller.go`:
- Around line 2508-2511: The current fallback flips any non-Enabled mode
(including an explicit Disabled) to Enabled when the deprecated annotation
exists; change the condition to only apply the annotation fallback when the HCP
mode is not explicitly set (e.g., empty/unspecified) rather than any mode other
than Enabled. Concretely, update the check around
hcp.Spec.Monitoring.MetricsForwarding.Mode so it only sets
hyperv1.MetricsForwardingModeEnabled from the deprecated
hcluster.Annotations[hyperv1.EnableMetricsForwarding] when the existing mode is
the unset/zero value (not when it equals hyperv1.MetricsForwardingModeDisabled
or any explicit value).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 9bad19ca-0e30-40f1-88ee-d8aca6240665

📥 Commits

Reviewing files that changed from the base of the PR and between e8aa9bb and 996709e.

⛔ Files ignored due to path filters (44)
  • api/hypershift/v1beta1/zz_generated.deepcopy.go is excluded by !**/zz_generated*.go, !**/zz_generated*
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/AAA_ungated.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/ClusterUpdateAcceptRisks.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/ClusterVersionOperatorConfiguration.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/ExternalOIDC.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/ExternalOIDCWithUIDAndExtraClaimMappings.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/ExternalOIDCWithUpstreamParity.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/GCPPlatform.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/HCPEtcdBackup.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/HyperShiftOnlyDynamicResourceAllocation.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/ImageStreamImportMode.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/KMSEncryptionProvider.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/OpenStack.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/TLSAdherence.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/AAA_ungated.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/ClusterUpdateAcceptRisks.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/ClusterVersionOperatorConfiguration.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/ExternalOIDC.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/ExternalOIDCWithUIDAndExtraClaimMappings.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/ExternalOIDCWithUpstreamParity.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/GCPPlatform.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/HCPEtcdBackup.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/HyperShiftOnlyDynamicResourceAllocation.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/ImageStreamImportMode.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/KMSEncryptionProvider.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/OpenStack.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/TLSAdherence.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • client/applyconfiguration/hypershift/v1beta1/hostedclusterspec.go is excluded by !client/**
  • client/applyconfiguration/hypershift/v1beta1/hostedcontrolplanespec.go is excluded by !client/**
  • client/applyconfiguration/hypershift/v1beta1/metricsforwardingspec.go is excluded by !client/**
  • client/applyconfiguration/hypershift/v1beta1/monitoringspec.go is excluded by !client/**
  • client/applyconfiguration/utils.go is excluded by !client/**
  • cmd/install/assets/crds/hypershift-operator/tests/hostedclusters.hypershift.openshift.io/stable.hostedclusters.monitoring.testsuite.yaml is excluded by !cmd/install/assets/**/*.yaml
  • cmd/install/assets/crds/hypershift-operator/zz_generated.crd-manifests/hostedclusters-Hypershift-CustomNoUpgrade.crd.yaml is excluded by !**/zz_generated.crd-manifests/**, !cmd/install/assets/**/*.yaml
  • cmd/install/assets/crds/hypershift-operator/zz_generated.crd-manifests/hostedclusters-Hypershift-Default.crd.yaml is excluded by !**/zz_generated.crd-manifests/**, !cmd/install/assets/**/*.yaml
  • cmd/install/assets/crds/hypershift-operator/zz_generated.crd-manifests/hostedclusters-Hypershift-TechPreviewNoUpgrade.crd.yaml is excluded by !**/zz_generated.crd-manifests/**, !cmd/install/assets/**/*.yaml
  • cmd/install/assets/crds/hypershift-operator/zz_generated.crd-manifests/hostedcontrolplanes-Hypershift-CustomNoUpgrade.crd.yaml is excluded by !**/zz_generated.crd-manifests/**, !cmd/install/assets/**/*.yaml
  • cmd/install/assets/crds/hypershift-operator/zz_generated.crd-manifests/hostedcontrolplanes-Hypershift-Default.crd.yaml is excluded by !**/zz_generated.crd-manifests/**, !cmd/install/assets/**/*.yaml
  • cmd/install/assets/crds/hypershift-operator/zz_generated.crd-manifests/hostedcontrolplanes-Hypershift-TechPreviewNoUpgrade.crd.yaml is excluded by !**/zz_generated.crd-manifests/**, !cmd/install/assets/**/*.yaml
  • docs/content/reference/aggregated-docs.md is excluded by !docs/content/reference/aggregated-docs.md
  • docs/content/reference/api.md is excluded by !docs/content/reference/api.md
  • vendor/github.com/openshift/hypershift/api/hypershift/v1beta1/hosted_controlplane.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/openshift/hypershift/api/hypershift/v1beta1/hostedcluster_types.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/openshift/hypershift/api/hypershift/v1beta1/zz_generated.deepcopy.go is excluded by !vendor/**, !**/vendor/**, !**/zz_generated*.go, !**/zz_generated*
📒 Files selected for processing (11)
  • api/hypershift/v1beta1/hosted_controlplane.go
  • api/hypershift/v1beta1/hostedcluster_types.go
  • control-plane-operator/controllers/hostedcontrolplane/hostedcontrolplane_controller.go
  • control-plane-operator/controllers/hostedcontrolplane/v2/endpoint_resolver/component.go
  • control-plane-operator/controllers/hostedcontrolplane/v2/endpoint_resolver/component_test.go
  • control-plane-operator/controllers/hostedcontrolplane/v2/metrics_proxy/component.go
  • control-plane-operator/hostedclusterconfigoperator/controllers/resources/resources.go
  • control-plane-operator/hostedclusterconfigoperator/controllers/resources/resources_test.go
  • hypershift-operator/controllers/hostedcluster/hostedcluster_controller.go
  • test/e2e/util/util_metrics_proxy.go
  • test/e2e/v2/tests/hosted_cluster_metrics_test.go

Comment thread api/hypershift/v1beta1/hosted_controlplane.go
Comment thread hypershift-operator/controllers/hostedcluster/hostedcluster_controller.go Outdated
Comment thread api/hypershift/v1beta1/hostedcluster_types.go Outdated
@muraee muraee force-pushed the metrics-forwarding-api branch from 996709e to 89814ff Compare May 28, 2026 15:15
@github-actions github-actions Bot temporarily deployed to docs-preview/pr-8626 May 28, 2026 15:21 Inactive

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@control-plane-operator/hostedclusterconfigoperator/controllers/resources/resources.go`:
- Around line 951-952: The code directly reads
hcp.Spec.Monitoring.MetricsForwarding.Mode which can panic when Monitoring or
MetricsForwarding is nil; update the conditional to first nil-check
hcp.Spec.Monitoring and hcp.Spec.Monitoring.MetricsForwarding and only compare
Mode to hyperv1.MetricsForwardingModeEnabled when both are non-nil, otherwise
treat it as not enabled and call return k8sutil.DeleteAllIfNeeded(ctx, r.client,
deployment, cm, servingCA, podMonitor); ensure you reference the same symbols
(hcp, Spec, Monitoring, MetricsForwarding, Mode,
hyperv1.MetricsForwardingModeEnabled) so the branch exactly mirrors the intended
behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 9bc66ee1-87cc-4ca1-8f51-fda6d9f9d236

📥 Commits

Reviewing files that changed from the base of the PR and between 996709e and 89814ff.

⛔ Files ignored due to path filters (44)
  • api/hypershift/v1beta1/zz_generated.deepcopy.go is excluded by !**/zz_generated*.go, !**/zz_generated*
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/AAA_ungated.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/ClusterUpdateAcceptRisks.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/ClusterVersionOperatorConfiguration.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/ExternalOIDC.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/ExternalOIDCWithUIDAndExtraClaimMappings.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/ExternalOIDCWithUpstreamParity.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/GCPPlatform.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/HCPEtcdBackup.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/HyperShiftOnlyDynamicResourceAllocation.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/ImageStreamImportMode.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/KMSEncryptionProvider.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/OpenStack.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/TLSAdherence.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/AAA_ungated.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/ClusterUpdateAcceptRisks.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/ClusterVersionOperatorConfiguration.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/ExternalOIDC.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/ExternalOIDCWithUIDAndExtraClaimMappings.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/ExternalOIDCWithUpstreamParity.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/GCPPlatform.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/HCPEtcdBackup.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/HyperShiftOnlyDynamicResourceAllocation.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/ImageStreamImportMode.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/KMSEncryptionProvider.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/OpenStack.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/TLSAdherence.yaml is excluded by !**/zz_generated.featuregated-crd-manifests/**
  • client/applyconfiguration/hypershift/v1beta1/hostedclusterspec.go is excluded by !client/**
  • client/applyconfiguration/hypershift/v1beta1/hostedcontrolplanespec.go is excluded by !client/**
  • client/applyconfiguration/hypershift/v1beta1/metricsforwardingspec.go is excluded by !client/**
  • client/applyconfiguration/hypershift/v1beta1/monitoringspec.go is excluded by !client/**
  • client/applyconfiguration/utils.go is excluded by !client/**
  • cmd/install/assets/crds/hypershift-operator/tests/hostedclusters.hypershift.openshift.io/stable.hostedclusters.monitoring.testsuite.yaml is excluded by !cmd/install/assets/**/*.yaml
  • cmd/install/assets/crds/hypershift-operator/zz_generated.crd-manifests/hostedclusters-Hypershift-CustomNoUpgrade.crd.yaml is excluded by !**/zz_generated.crd-manifests/**, !cmd/install/assets/**/*.yaml
  • cmd/install/assets/crds/hypershift-operator/zz_generated.crd-manifests/hostedclusters-Hypershift-Default.crd.yaml is excluded by !**/zz_generated.crd-manifests/**, !cmd/install/assets/**/*.yaml
  • cmd/install/assets/crds/hypershift-operator/zz_generated.crd-manifests/hostedclusters-Hypershift-TechPreviewNoUpgrade.crd.yaml is excluded by !**/zz_generated.crd-manifests/**, !cmd/install/assets/**/*.yaml
  • cmd/install/assets/crds/hypershift-operator/zz_generated.crd-manifests/hostedcontrolplanes-Hypershift-CustomNoUpgrade.crd.yaml is excluded by !**/zz_generated.crd-manifests/**, !cmd/install/assets/**/*.yaml
  • cmd/install/assets/crds/hypershift-operator/zz_generated.crd-manifests/hostedcontrolplanes-Hypershift-Default.crd.yaml is excluded by !**/zz_generated.crd-manifests/**, !cmd/install/assets/**/*.yaml
  • cmd/install/assets/crds/hypershift-operator/zz_generated.crd-manifests/hostedcontrolplanes-Hypershift-TechPreviewNoUpgrade.crd.yaml is excluded by !**/zz_generated.crd-manifests/**, !cmd/install/assets/**/*.yaml
  • docs/content/reference/aggregated-docs.md is excluded by !docs/content/reference/aggregated-docs.md
  • docs/content/reference/api.md is excluded by !docs/content/reference/api.md
  • vendor/github.com/openshift/hypershift/api/hypershift/v1beta1/hosted_controlplane.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/openshift/hypershift/api/hypershift/v1beta1/hostedcluster_types.go is excluded by !vendor/**, !**/vendor/**
  • vendor/github.com/openshift/hypershift/api/hypershift/v1beta1/zz_generated.deepcopy.go is excluded by !vendor/**, !**/vendor/**, !**/zz_generated*.go, !**/zz_generated*
📒 Files selected for processing (11)
  • api/hypershift/v1beta1/hosted_controlplane.go
  • api/hypershift/v1beta1/hostedcluster_types.go
  • control-plane-operator/controllers/hostedcontrolplane/hostedcontrolplane_controller.go
  • control-plane-operator/controllers/hostedcontrolplane/v2/endpoint_resolver/component.go
  • control-plane-operator/controllers/hostedcontrolplane/v2/endpoint_resolver/component_test.go
  • control-plane-operator/controllers/hostedcontrolplane/v2/metrics_proxy/component.go
  • control-plane-operator/hostedclusterconfigoperator/controllers/resources/resources.go
  • control-plane-operator/hostedclusterconfigoperator/controllers/resources/resources_test.go
  • hypershift-operator/controllers/hostedcluster/hostedcluster_controller.go
  • test/e2e/util/util_metrics_proxy.go
  • test/e2e/v2/tests/hosted_cluster_metrics_test.go
🚧 Files skipped from review as they are similar to previous changes (7)
  • control-plane-operator/controllers/hostedcontrolplane/v2/endpoint_resolver/component.go
  • test/e2e/v2/tests/hosted_cluster_metrics_test.go
  • api/hypershift/v1beta1/hosted_controlplane.go
  • control-plane-operator/controllers/hostedcontrolplane/hostedcontrolplane_controller.go
  • test/e2e/util/util_metrics_proxy.go
  • control-plane-operator/controllers/hostedcontrolplane/v2/endpoint_resolver/component_test.go
  • control-plane-operator/hostedclusterconfigoperator/controllers/resources/resources_test.go

@codecov

codecov Bot commented May 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 41.49%. Comparing base (ad3da77) to head (a9ebe53).

Files with missing lines Patch % Lines
...ostedcontrolplane/hostedcontrolplane_controller.go 50.00% 2 Missing and 2 partials ⚠️
...trollers/hostedcluster/hostedcluster_controller.go 76.92% 2 Missing and 1 partial ⚠️
...s/hostedcontrolplane/v2/metrics_proxy/component.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8626   +/-   ##
=======================================
  Coverage   41.49%   41.49%           
=======================================
  Files         756      756           
  Lines       93648    93662   +14     
=======================================
+ Hits        38855    38864    +9     
- Misses      52057    52060    +3     
- Partials     2736     2738    +2     
Files with missing lines Coverage Δ
...stedcontrolplane/v2/endpoint_resolver/component.go 12.00% <100.00%> (-3.39%) ⬇️
...rconfigoperator/controllers/resources/resources.go 56.70% <100.00%> (ø)
...s/hostedcontrolplane/v2/metrics_proxy/component.go 0.00% <0.00%> (ø)
...trollers/hostedcluster/hostedcluster_controller.go 45.51% <76.92%> (+0.08%) ⬆️
...ostedcontrolplane/hostedcontrolplane_controller.go 45.66% <50.00%> (-0.04%) ⬇️
Flag Coverage Δ
cmd-support 34.87% <ø> (ø)
cpo-hostedcontrolplane 43.50% <50.00%> (-0.01%) ⬇️
cpo-other 43.17% <100.00%> (ø)
hypershift-operator 51.58% <76.92%> (+0.01%) ⬆️
other 31.64% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@muraee

muraee commented May 28, 2026

Copy link
Copy Markdown
Contributor Author

/retest

@muraee muraee force-pushed the metrics-forwarding-api branch from 89814ff to 94e176b Compare May 28, 2026 16:36

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
hypershift-operator/controllers/hostedcluster/hostedcluster_controller_test.go (1)

616-690: ⚡ Quick win

Add a backward-compat test for metricsSet + deprecated annotation together.

You already test metricsSet alone and annotation-only fallback, but not the combined case. Add one case where monitoring.metricsSet is set and hyperv1.EnableMetricsForwarding is present, and assert both MetricsSet is preserved and Mode becomes Enabled.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@hypershift-operator/controllers/hostedcluster/hostedcluster_controller_test.go`
around lines 616 - 690, Add a new test case in the tests slice that sets
monitoring.MetricsSet (e.g. hyperv1.MetricsSetAll) and also includes the
deprecated annotation hyperv1.EnableMetricsForwarding: "true"; set
expectedMonitoring to preserve MetricsSet and include MetricsForwarding.Mode:
hyperv1.MetricsForwardingModeEnabled so the test verifies that MetricsSet is
preserved and Mode becomes Enabled when the annotation is present (refer to the
tests variable, monitoring, annotations, expectedMonitoring, MetricsSet and
MetricsForwarding.Mode symbols).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@hypershift-operator/controllers/hostedcluster/hostedcluster_controller_test.go`:
- Around line 616-690: Add a new test case in the tests slice that sets
monitoring.MetricsSet (e.g. hyperv1.MetricsSetAll) and also includes the
deprecated annotation hyperv1.EnableMetricsForwarding: "true"; set
expectedMonitoring to preserve MetricsSet and include MetricsForwarding.Mode:
hyperv1.MetricsForwardingModeEnabled so the test verifies that MetricsSet is
preserved and Mode becomes Enabled when the annotation is present (refer to the
tests variable, monitoring, annotations, expectedMonitoring, MetricsSet and
MetricsForwarding.Mode symbols).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: e1f7770b-5abc-49f8-b1c8-d2d155d6fd33

📥 Commits

Reviewing files that changed from the base of the PR and between 89814ff and 94e176b.

⛔ Files ignored due to path filters (1)
  • cmd/install/assets/crds/hypershift-operator/tests/hostedclusters.hypershift.openshift.io/stable.hostedclusters.monitoring.testsuite.yaml is excluded by !cmd/install/assets/**/*.yaml
📒 Files selected for processing (10)
  • control-plane-operator/controllers/hostedcontrolplane/hostedcontrolplane_controller.go
  • control-plane-operator/controllers/hostedcontrolplane/v2/endpoint_resolver/component.go
  • control-plane-operator/controllers/hostedcontrolplane/v2/endpoint_resolver/component_test.go
  • control-plane-operator/controllers/hostedcontrolplane/v2/metrics_proxy/component.go
  • control-plane-operator/hostedclusterconfigoperator/controllers/resources/resources.go
  • control-plane-operator/hostedclusterconfigoperator/controllers/resources/resources_test.go
  • hypershift-operator/controllers/hostedcluster/hostedcluster_controller.go
  • hypershift-operator/controllers/hostedcluster/hostedcluster_controller_test.go
  • test/e2e/util/util_metrics_proxy.go
  • test/e2e/v2/tests/hosted_cluster_metrics_test.go
🚧 Files skipped from review as they are similar to previous changes (8)
  • test/e2e/v2/tests/hosted_cluster_metrics_test.go
  • control-plane-operator/controllers/hostedcontrolplane/v2/endpoint_resolver/component.go
  • test/e2e/util/util_metrics_proxy.go
  • control-plane-operator/hostedclusterconfigoperator/controllers/resources/resources.go
  • hypershift-operator/controllers/hostedcluster/hostedcluster_controller.go
  • control-plane-operator/controllers/hostedcontrolplane/hostedcontrolplane_controller.go
  • control-plane-operator/controllers/hostedcontrolplane/v2/endpoint_resolver/component_test.go
  • control-plane-operator/hostedclusterconfigoperator/controllers/resources/resources_test.go

@muraee

muraee commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

/retest

@github-actions github-actions Bot temporarily deployed to docs-preview/pr-8626 June 5, 2026 13:21 Inactive
@muraee

muraee commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

/test e2e-aws

@csrwng csrwng left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One comment

// +kubebuilder:validation:MinProperties=1
type MonitoringSpec struct {
// metricsForwarding configures forwarding of metrics from the hosted cluster
// to the management cluster's monitoring stack.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This doesn't sound right. We're forwarding metrics from the control plane into the hosted cluster's monitoring stack.

Also, MetricsForwarding by itself may not be descriptive enough for what it does (metrics could be forwarded in multiple ways)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done. Fixed the description direction — it now reads "forwarding of control plane metrics into the hosted cluster's monitoring stack" in both MonitoringSpec and the field-level godocs. Regarding naming, since metricsForwarding is scoped under monitoring (i.e. spec.monitoring.metricsForwarding), I think the context makes it clear. The improved godoc should disambiguate what kind of forwarding this is. Let me know if you'd still prefer a rename.


AI-assisted response via Claude Code

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

was this fix pushed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@enxebre yes

@yuqi-zhang yuqi-zhang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Some general godoc suggestions per openshift/api conventions

Comment thread api/hypershift/v1beta1/hostedcluster_types.go Outdated
Comment thread api/hypershift/v1beta1/hostedcluster_types.go
Comment thread api/hypershift/v1beta1/hostedcluster_types.go
@github-actions github-actions Bot temporarily deployed to docs-preview/pr-8626 June 8, 2026 09:15 Inactive
@muraee muraee force-pushed the metrics-forwarding-api branch from 39a06cf to b839f14 Compare June 8, 2026 13:16
@github-actions github-actions Bot temporarily deployed to docs-preview/pr-8626 June 8, 2026 13:22 Inactive
@hypershift-jira-solve-ci

hypershift-jira-solve-ci Bot commented Jun 8, 2026

Copy link
Copy Markdown

Now I have the complete root cause. Let me compile the final report.

Test Failure Analysis Complete

Job Information

Test Failure Analysis

Error

codecov/project: 41.49% (-4.30%) compared to 72ec4e7
Project coverage dropped from 45.79% to 41.49% (-4.30%).
Files: 440 → 756 (+316). Lines: 52,788 → 93,662 (+40,874).

Summary

The codecov/project check failed because the PR branch is 133 commits behind main and is missing the carryforward: true flag definitions that were added to codecov.yml on main via PR #8642 (merged 2026-06-02). Without carryforward flags, Codecov treats coverage data from unuploaded test shards as empty (0%), causing the project total to swing wildly depending on shard upload timing. This is a branch staleness issue, not a code quality problem — the PR's own patch coverage (56.52%) actually passes the target (45.79%), and individual file coverages are mostly improving.

Root Cause

The HyperShift repo runs unit tests in 5 parallel shards (cpo-hostedcontrolplane, cpo-other, hypershift-operator, cmd-support, other), each uploading a separate coverage report to Codecov. The codecov/project check is computed from the union of all shard reports.

The fix that this branch is missing: PR #8642 ("CNTRLPLANE-3535: Add codecov carryforward flags to stabilize project coverage checks") was merged to main on 2026-06-02. It added carryforward: true to all 5 flag definitions in codecov.yml. With carryforward enabled, when a shard hasn't uploaded coverage yet for a given commit, Codecov uses that shard's last-known coverage data instead of treating it as empty (0%).

Why this PR fails: The PR branch was forked from main at commit 72ec4e7 (2026-05-28), which is before #8642 was merged. The branch's codecov.yml is missing the flags: section entirely. Without carryforward flags:

  1. Coverage is computed from whichever shards happened to upload by the time the status was posted
  2. Shards that hadn't uploaded yet are counted as 0% coverage over their files
  3. This artificially inflates the file count (440 → 756, +316 files) and line count (52,788 → 93,662, +40,874 lines) because uncovered files from missing shard reports are now included with zero hits
  4. The result is the observed -4.30% drop (45.79% → 41.49%)

This is a known, documented issue — the body of PR #8642 specifically cites that "coverage on the same commit swings between ~40% and ~47% depending on shard upload timing."

Recommendations
  1. Rebase the PR branch onto current main — this is the only fix needed. It will pick up the carryforward: true flags from PR CNTRLPLANE-3535: Add codecov carryforward flags to stabilize project coverage checks #8642 and stabilize the codecov/project check:

    git fetch origin main
    git rebase origin/main
    git push --force-with-lease
  2. No code changes required — the PR's patch coverage is 56.52%, which exceeds the project target of 45.79%. The codecov/patch check already passes. The 10 lines with missing coverage (5 in hostedcluster_controller.go, 4 in hostedcontrolplane_controller.go, 1 in metrics_proxy/component.go) are not the cause of the failure.

  3. For ongoing prevention — the team should consider enabling branch protection rules that warn contributors when their branch is significantly behind main, or adding automated rebase reminders for stale PRs.

Evidence
Evidence Detail
Check conclusion failurecodecov/project: 41.49% (-4.30%) compared to 72ec4e7
codecov/patch status success — 56.52% patch coverage (target 45.79%)
Branch staleness 133 commits behind main; base commit 72ec4e7 from 2026-05-28
Missing config PR branch codecov.yml has no flags: section and no carryforward settings
Fix already on main PR #8642 (merged 2026-06-02) added carryforward: true to all 5 shard flags
File count inflation Files jumped from 440 (base) to 756 (head), +316 — from missing shard data counted as empty
Line count inflation Lines jumped from 52,788 to 93,662, +40,874 — same root cause
Indirect changes 346 files with "indirect coverage changes" — shard timing artifacts, not real regressions
PR #8642 description "Without carryforward, Codecov recomputes the project total after each shard arrives... coverage on the same commit swings between ~40% and ~47%"

muraee and others added 3 commits June 8, 2026 15:57
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 (Enabled/Disabled) 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

Signed-off-by: Mulham Raee <mulham.raee@gmail.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@openshift-ci

openshift-ci Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

@muraee: all tests passed!

Full PR test history. Your PR dashboard.

Details

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. I understand the commands that are listed here.

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

Labels

area/api Indicates the PR includes changes for the API area/cli Indicates the PR includes changes for CLI area/control-plane-operator Indicates the PR includes changes for the control plane operator - in an OCP release area/documentation Indicates the PR includes changes for documentation area/hypershift-operator Indicates the PR includes changes for the hypershift operator and API - outside an OCP release area/testing Indicates the PR includes changes for e2e testing jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants