Skip to content

OCPBUGS-112272: node ServiceMonitor serverName uses guest namespace on HyperShift - #603

Open
bryan-cox wants to merge 1 commit into
openshift:mainfrom
bryan-cox:OCPBUGS-112272
Open

OCPBUGS-112272: node ServiceMonitor serverName uses guest namespace on HyperShift#603
bryan-cox wants to merge 1 commit into
openshift:mainfrom
bryan-cox:OCPBUGS-112272

Conversation

@bryan-cox

Copy link
Copy Markdown
Member

What

On HyperShift, the node metrics ServiceMonitor that csi-operator creates in the guest cluster set its TLS serverName from the control-plane namespace (${NAMESPACE}) instead of the guest namespace. The name never matched the service serving certificate, so every node metrics scrape failed certificate verification, the node CSI driver metrics target was permanently down, and TargetDown fired continuously.

Impact is limited to observability — CSI provisioning and attach/detach are unaffected — but node CSI metrics are never collected and the permanently-failing target produces continuous alert noise.

Root cause

The shared patch assets/common/metrics/service_monitor_add_port.yaml.patch hardcoded ${NAMESPACE} in serverName. That patch is applied by generateDriverMetricsService() for both the controller monitor (where ${NAMESPACE} is correct, since the controller runs control-plane side) and the node monitor (where it is wrong, since the node DaemonSet and its metrics Service run guest side).

In pkg/driver/common/operator/replacer.go the two namespace variables resolve to different values under HyperShift:

  • ${NAMESPACE} → control-plane namespace
  • ${NODE_NAMESPACE} → guest namespace

On standalone both resolve to openshift-cluster-csi-drivers, which is why the defect was invisible there.

Fix

  • Introduce a ${MONITOR_NAMESPACE} template variable in the shared ServiceMonitor patch.
  • Resolve it per service prefix in the generator (monitorNamespaceVariable): ${NODE_NAMESPACE} for the node monitor, ${NAMESPACE} for the controller monitor. Wired into both generateDriverMetricsService and generateSidecarMetricsServices.
  • Regenerated assets via make update.

Scope / safety

  • HyperShift-only behavior change. On standalone, ${NAMESPACE} and ${NODE_NAMESPACE} both resolve to openshift-cluster-csi-drivers, so the rendered serverName is byte-for-byte identical to before — only the template variable changed.
  • Controller ServiceMonitors unchanged across all drivers (still ${NAMESPACE}).
  • Fix is in shared generator code, so any driver enabling node metrics inherits it. azure-disk is currently the only driver that generates a node metrics ServiceMonitor.

Testing

  • Added regression tests at the generator seam (pkg/generator/asset_generator_test.go) asserting the node monitor resolves to ${NODE_NAMESPACE} and the controller monitor to ${NAMESPACE}, using the real embedded assets.
  • make update is idempotent (no unintended diffs), go build ./... clean, go test ./pkg/... all pass.

Acceptance criteria

  • Node ServiceMonitor serverName resolves to the guest namespace, matching the serving cert SANs.
  • Generated HyperShift node asset renders serverName from ${NODE_NAMESPACE}.
  • Controller metrics ServiceMonitor unchanged (${NAMESPACE}).
  • Standalone generated assets remain functionally correct.
  • Assets regenerated via the generator/make target; fix covers all affected driver overlays via shared code.

…n HyperShift

The node metrics ServiceMonitor's TLS serverName was built from ${NAMESPACE}
(control-plane namespace) instead of the guest namespace. On HyperShift these
namespaces differ, so serverName never matched the serving certificate's SANs,
every node metrics scrape failed certificate verification, and TargetDown fired
continuously. On standalone the two namespaces are identical, so the defect was
invisible there.

The shared patch common/metrics/service_monitor_add_port.yaml.patch hardcoded
${NAMESPACE}, which is only correct for the controller monitor. The node metrics
Service runs guest-side and its serving certificate is issued for the guest
namespace.

Introduce a ${MONITOR_NAMESPACE} template variable in the patch and resolve it
per service prefix in the generator: ${NODE_NAMESPACE} for the node monitor and
${NAMESPACE} for the controller monitor. Standalone output is functionally
unchanged since both variables resolve to openshift-cluster-csi-drivers.
@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 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 Aug 19, 2026
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Aug 19, 2026
@openshift-ci

openshift-ci Bot commented Aug 19, 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

@openshift-ci-robot openshift-ci-robot added the jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. label Aug 19, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@bryan-cox: This pull request references Jira Issue OCPBUGS-112272, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.1.0) matches configured target version for branch (5.1.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, POST)

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

What

On HyperShift, the node metrics ServiceMonitor that csi-operator creates in the guest cluster set its TLS serverName from the control-plane namespace (${NAMESPACE}) instead of the guest namespace. The name never matched the service serving certificate, so every node metrics scrape failed certificate verification, the node CSI driver metrics target was permanently down, and TargetDown fired continuously.

Impact is limited to observability — CSI provisioning and attach/detach are unaffected — but node CSI metrics are never collected and the permanently-failing target produces continuous alert noise.

Root cause

The shared patch assets/common/metrics/service_monitor_add_port.yaml.patch hardcoded ${NAMESPACE} in serverName. That patch is applied by generateDriverMetricsService() for both the controller monitor (where ${NAMESPACE} is correct, since the controller runs control-plane side) and the node monitor (where it is wrong, since the node DaemonSet and its metrics Service run guest side).

In pkg/driver/common/operator/replacer.go the two namespace variables resolve to different values under HyperShift:

  • ${NAMESPACE} → control-plane namespace
  • ${NODE_NAMESPACE} → guest namespace

On standalone both resolve to openshift-cluster-csi-drivers, which is why the defect was invisible there.

Fix

  • Introduce a ${MONITOR_NAMESPACE} template variable in the shared ServiceMonitor patch.
  • Resolve it per service prefix in the generator (monitorNamespaceVariable): ${NODE_NAMESPACE} for the node monitor, ${NAMESPACE} for the controller monitor. Wired into both generateDriverMetricsService and generateSidecarMetricsServices.
  • Regenerated assets via make update.

Scope / safety

  • HyperShift-only behavior change. On standalone, ${NAMESPACE} and ${NODE_NAMESPACE} both resolve to openshift-cluster-csi-drivers, so the rendered serverName is byte-for-byte identical to before — only the template variable changed.
  • Controller ServiceMonitors unchanged across all drivers (still ${NAMESPACE}).
  • Fix is in shared generator code, so any driver enabling node metrics inherits it. azure-disk is currently the only driver that generates a node metrics ServiceMonitor.

Testing

  • Added regression tests at the generator seam (pkg/generator/asset_generator_test.go) asserting the node monitor resolves to ${NODE_NAMESPACE} and the controller monitor to ${NAMESPACE}, using the real embedded assets.
  • make update is idempotent (no unintended diffs), go build ./... clean, go test ./pkg/... all pass.

Acceptance criteria

  • Node ServiceMonitor serverName resolves to the guest namespace, matching the serving cert SANs.
  • Generated HyperShift node asset renders serverName from ${NODE_NAMESPACE}.
  • Controller metrics ServiceMonitor unchanged (${NAMESPACE}).
  • Standalone generated assets remain functionally correct.
  • Assets regenerated via the generator/make target; fix covers all affected driver overlays via shared 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.

@coderabbitai

coderabbitai Bot commented Aug 19, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Enterprise

Run ID: fd4327c7-eaae-4f58-a942-79d4bf4ccf6a

📥 Commits

Reviewing files that changed from the base of the PR and between 9ce1841 and 82a49f1.

⛔ Files ignored due to path filters (2)
  • assets/overlays/azure-disk/generated/hypershift/node_servicemonitor.yaml is excluded by !**/generated/**
  • assets/overlays/azure-disk/generated/standalone/node_servicemonitor.yaml is excluded by !**/generated/**
📒 Files selected for processing (3)
  • assets/common/metrics/service_monitor_add_port.yaml.patch
  • pkg/generator/asset_generator.go
  • pkg/generator/asset_generator_test.go

Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review.


📝 Walkthrough

Walkthrough

The ServiceMonitor TLS serverName now uses ${MONITOR_NAMESPACE}. The generator selects ${NODE_NAMESPACE} for node metrics and ${NAMESPACE} for controller and other metrics. Driver and sidecar monitoring patches receive the selected namespace variable. Regression tests verify rendered node and controller ServiceMonitor assets.

🚥 Pre-merge checks | ✅ 15
✅ Passed checks (15 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 The added tests use static Go test function names and contain no generated names, timestamps, UUIDs, node names, namespaces with random suffixes, IPs, or other run-dependent values.
Test Structure And Quality ✅ Passed The added tests use Go's testing package, not Ginkgo. They perform no cluster operations or waits, create no resources, isolate one related behavior per test, and include diagnostic assertion messa...
Microshift Test Compatibility ✅ Passed The PR adds standard Go tests using package testing, not new Ginkgo e2e tests; therefore the MicroShift API compatibility check does not apply.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The PR adds only standard Go testing.Test unit tests; no Ginkgo e2e tests or multi-node/SNO assumptions are present.
Topology-Aware Scheduling Compatibility ✅ Passed The diff changes only ServiceMonitor TLS namespace substitution, generator replacements, and tests; it adds no affinity, topology spread, replica, selector, toleration, or PDB scheduling constraint.
Ote Binary Stdout Contract ✅ Passed The diff changes YAML, generator logic, and unit tests only; no process-level OTE setup changed, and changed Go files contain no stdout, fmt, log, or klog writes.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed The diff adds only standard-library unit tests in pkg/generator; it adds no Ginkgo e2e tests, IPv4 assumptions, external URLs, or connectivity requirements.
No-Weak-Crypto ✅ Passed The PR changes only ServiceMonitor namespace templating and tests; scans of all introduced lines found no MD5, SHA1, DES, RC4, Blowfish, ECB, custom crypto, or secret comparisons.
Container-Privileges ✅ Passed The PR diff changes ServiceMonitor serverName substitutions, generator replacements, generated assets, and tests; it adds no privileged, hostPID, hostNetwork, hostIPC, SYS_ADMIN, or allowPrivilegeE...
No-Sensitive-Data-In-Logs ✅ Passed The PR adds no application logging or logger imports. Changes contain only templated ServiceMonitor names and test diagnostics with synthetic values; the existing Logf call is unchanged.
Title check ✅ Passed The title clearly identifies the HyperShift node ServiceMonitor serverName defect and matches the main change.
Description check ✅ Passed The description directly explains the defect, root cause, fix, scope, and tests for the changeset.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@bryan-cox
bryan-cox marked this pull request as ready for review August 19, 2026 21:37
@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 Aug 19, 2026
@openshift-ci
openshift-ci Bot requested review from jsafrane and tsmetana August 19, 2026 21:37
@jsafrane

Copy link
Copy Markdown
Contributor

/lgtm
/approve

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Aug 21, 2026
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e-aws-csi
/test e2e-aws-ovn-upgrade
/test e2e-azure
/test e2e-azure-csi
/test e2e-azure-file-csi
/test e2e-azure-file-nfs-csi
/test e2e-azure-ovn-upgrade
/test e2e-gcp
/test e2e-gcp-csi
/test e2e-gcp-ovn-upgrade

Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e-azure-csi-extended
/test e2e-azure-csi-hypershift
/test e2e-azurestack-csi

@openshift-ci

openshift-ci Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bryan-cox, jsafrane

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

The pull request process is described 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 the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 21, 2026
@openshift-ci

openshift-ci Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

@bryan-cox: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-azurestack-csi 82a49f1 link false /test e2e-azurestack-csi
ci/prow/e2e-azure-csi-hypershift 82a49f1 link false /test e2e-azure-csi-hypershift

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

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants