Skip to content

[DO NOT MERGE] UPSTREAM: <carry>: fix kube_persistentvolume_plugin_type_counts#2673

Open
dfajmon wants to merge 1 commit into
openshift:masterfrom
dfajmon:OCPBUGS-44815
Open

[DO NOT MERGE] UPSTREAM: <carry>: fix kube_persistentvolume_plugin_type_counts#2673
dfajmon wants to merge 1 commit into
openshift:masterfrom
dfajmon:OCPBUGS-44815

Conversation

@dfajmon

@dfajmon dfajmon commented May 26, 2026

Copy link
Copy Markdown

What type of PR is this?

What this PR does / why we need it:

Which issue(s) this PR is related to:

Special notes for your reviewer:

Does this PR introduce a user-facing change?


Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


Summary by CodeRabbit

  • New Features
    • Improved persistent volume metrics: the controller explicitly tracks metric-capable volume plugins and includes local volume plugin metrics.
  • Tests
    • Added unit tests to validate reported volume plugin names for persistent volume metrics.

@openshift-ci-robot openshift-ci-robot added the backports/unvalidated-commits Indicates that not all commits come to merged upstream PRs. label May 26, 2026
@openshift-ci

openshift-ci Bot commented May 26, 2026

Copy link
Copy Markdown

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 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 26, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@dfajmon: the contents of this pull request could not be automatically validated.

The following commits could not be validated and must be approved by a top-level approver:

Comment /validate-backports to re-evaluate validity of the upstream PRs, for example when they are merged upstream.

@openshift-ci

openshift-ci Bot commented May 26, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: dfajmon
Once this PR has been reviewed and has the lgtm label, please assign bertinatto 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

@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown

Walkthrough

Persistent volume controller now probes metrics-capable volume plugins and wires them into a dedicated metrics plugin manager; the kube-controller-manager links the local volume plugin, metrics are registered against the metrics plugin manager, and a test verifies plugin-name resolution.

Changes

Metrics Plugin Manager Integration

Layer / File(s) Summary
Controller-manager plugin probing and local plugin link
cmd/kube-controller-manager/app/plugins.go
Import k8s.io/kubernetes/pkg/volume/local and append local.ProbeVolumePlugins() results to the controller-manager's probed plugin set.
Metrics plugin probing in controller construction
cmd/kube-controller-manager/app/core.go
newPersistentVolumeBinderController calls ProbePersistentVolumePlugins and assigns the result to ControllerParameters.MetricsVolumePlugins, returning an error if probing fails.
Metrics plugin manager and controller wiring
pkg/controller/volume/persistentvolume/pv_controller_base.go, pkg/controller/volume/persistentvolume/pv_controller.go
ControllerParameters gains MetricsVolumePlugins; PersistentVolumeController gains metricsPluginMgr. NewController initializes metricsPluginMgr from p.MetricsVolumePlugins.
Metrics registration uses metricsPluginMgr
pkg/controller/volume/persistentvolume/pv_controller_base.go
Controller startup metrics registration now registers caches with &ctrl.metricsPluginMgr instead of &ctrl.volumePluginMgr.
Plugin name resolution test
pkg/controller/volume/persistentvolume/metrics/metrics_test.go
Adds TestGetPVPluginName to verify getPVPluginName returns kubernetes.io/csi:<driver> when CSI plugins are registered and pluginNameNotAvailable when absent.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error, 1 warning)

Check name Status Explanation Resolution
No-Sensitive-Data-In-Logs ❌ Error Error wrapping with %w exposes internal file paths from recycler pod template loading failures, potentially revealing infrastructure details. Avoid using %w with errors that may contain file paths; sanitize or wrap underlying errors to hide infrastructure-level file paths from logs.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (13 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly addresses the main purpose of the PR—fixing the kube_persistentvolume_plugin_type_counts metric by implementing a separate metrics plugin manager. However, the [DO NOT MERGE] prefix and placeholder text '' reduce clarity about the actual change.
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 PR adds test with stable, deterministic subtest names. No Ginkgo tests; test names contain no dynamic content or generated identifiers.
Test Structure And Quality ✅ Passed No Ginkgo tests are added in this PR. The test in metrics_test.go uses standard Go testing (testing package with t.Run), not Ginkgo framework, so the Ginkgo test quality check does not apply.
Microshift Test Compatibility ✅ Passed PR adds only one test file (metrics_test.go) containing TestGetPVPluginName - a standard Go unit test, not a Ginkgo e2e test. Check applies only to Ginkgo e2e tests.
Single Node Openshift (Sno) Test Compatibility ✅ Passed PR adds only standard Go unit tests (testing.T), not Ginkgo e2e tests. Custom check for SNO compatibility is not applicable.
Topology-Aware Scheduling Compatibility ✅ Passed PR modifies persistent volume controller metrics logic without introducing scheduling constraints, pod affinity rules, or topology-specific assumptions required by this check.
Ote Binary Stdout Contract ✅ Passed PR modifies kube-controller-manager app code. No process-level stdout writes found (no fmt/log/klog to stdout). Unit test is standard Go test, not OTE test binary.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed The added test is a standard Go unit test (not a Ginkgo e2e test) with no IPv4 assumptions or external connectivity requirements. It uses mock objects and fake hosts for isolated testing.
No-Weak-Crypto ✅ Passed No weak cryptographic algorithms (MD5, SHA1, DES, RC4, 3DES, Blowfish, ECB), custom crypto implementations, or non-constant-time secret comparisons found in the PR.
Container-Privileges ✅ Passed PR contains only Go source code files (.go); no container/Kubernetes manifests present to check for privileged 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 `@cmd/kube-controller-manager/app/core.go`:
- Around line 334-336: The error return in newPersistentVolumeBinderController
incorrectly returns three values; change the error path in the metrics volume
plugin probe to return only (nil, error) by removing the extraneous boolean and
wrap the original probe error using fmt.Errorf("failed to probe metrics volume
plugins when starting persistentvolume controller: %w", err) so the function
signature (Controller, error) is respected and the underlying error is
preserved.
🪄 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: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 55e2cc95-d7d6-404c-bb43-74e4598e3128

📥 Commits

Reviewing files that changed from the base of the PR and between 99b75aa and 5c2d4b1.

📒 Files selected for processing (5)
  • cmd/kube-controller-manager/app/core.go
  • cmd/kube-controller-manager/app/plugins.go
  • pkg/controller/volume/persistentvolume/metrics/metrics_test.go
  • pkg/controller/volume/persistentvolume/pv_controller.go
  • pkg/controller/volume/persistentvolume/pv_controller_base.go

Comment thread cmd/kube-controller-manager/app/core.go
@openshift-ci-robot

Copy link
Copy Markdown

@dfajmon: the contents of this pull request could not be automatically validated.

The following commits could not be validated and must be approved by a top-level approver:

Comment /validate-backports to re-evaluate validity of the upstream PRs, for example when they are merged upstream.

@dfajmon dfajmon changed the title UPSTREAM: <carry>: fix kube_persistentvolume_plugin_type_counts missi… [DO NOT MERGE] UPSTREAM: <carry>: fix kube_persistentvolume_plugin_type_counts May 27, 2026
@dfajmon dfajmon marked this pull request as ready for review May 28, 2026 12:49
@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
@openshift-ci openshift-ci Bot requested review from bertinatto and jacobsee May 28, 2026 12:50
…ng plugin_name

Commit 9e29f95 refactored KCM volume plugins, replacing
ProbeControllerVolumePlugins (which included CSI) with
ProbeProvisionableRecyclableVolumePlugins (filtered to
Provisionable/Deletable/Recyclable). The CSI plugin implements none
of those interfaces, so it was excluded from volumePluginMgr.

metrics.Register was still using &ctrl.volumePluginMgr, so
getPVPluginName() -> FindPluginBySpec() failed for CSI PVs,
falling back to "N/A" instead of e.g. "kubernetes.io/csi:ebs.csi.aws.com".

Fix: initialize a separate metricsPluginMgr with all plugins
(ProbePersistentVolumePlugins, no filter) and pass it to
metrics.Register.

Fixes: OCPBUGS-44815

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@openshift-ci-robot

Copy link
Copy Markdown

@dfajmon: the contents of this pull request could not be automatically validated.

The following commits could not be validated and must be approved by a top-level approver:

Comment /validate-backports to re-evaluate validity of the upstream PRs, for example when they are merged upstream.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 `@pkg/controller/volume/persistentvolume/pv_controller_base.go`:
- Around line 103-105: If P.MetricsVolumePlugins is nil/empty, fall back to
P.VolumePlugins before calling controller.metricsPluginMgr.InitPlugins so
existing callers that omit metrics plugins keep previous behavior; update the
call site that currently passes P.MetricsVolumePlugins to use a local variable
(e.g., metricsPlugins := P.MetricsVolumePlugins; if len(metricsPlugins) == 0 {
metricsPlugins = P.VolumePlugins }) and then call
controller.metricsPluginMgr.InitPlugins(metricsPlugins, nil, controller) to
preserve backward compatibility (symbols to locate: P.MetricsVolumePlugins,
P.VolumePlugins, controller.metricsPluginMgr.InitPlugins in
pv_controller_base.go).
🪄 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: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 3a74ad02-73b3-4c37-9ded-7269080991d0

📥 Commits

Reviewing files that changed from the base of the PR and between dd4a857 and 1667c42.

📒 Files selected for processing (5)
  • cmd/kube-controller-manager/app/core.go
  • cmd/kube-controller-manager/app/plugins.go
  • pkg/controller/volume/persistentvolume/metrics/metrics_test.go
  • pkg/controller/volume/persistentvolume/pv_controller.go
  • pkg/controller/volume/persistentvolume/pv_controller_base.go
🚧 Files skipped from review as they are similar to previous changes (4)
  • cmd/kube-controller-manager/app/plugins.go
  • pkg/controller/volume/persistentvolume/metrics/metrics_test.go
  • pkg/controller/volume/persistentvolume/pv_controller.go
  • cmd/kube-controller-manager/app/core.go

Comment on lines +103 to +105
if err := controller.metricsPluginMgr.InitPlugins(p.MetricsVolumePlugins, nil /* prober */, controller); err != nil {
return nil, fmt.Errorf("could not initialize metrics volume plugins for PersistentVolume Controller: %w", err)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add a backward-compatible fallback for metrics plugins.

If MetricsVolumePlugins is omitted by existing constructor callers, metricsPluginMgr initializes empty and plugin labeling can silently regress to fallback values. Default to VolumePlugins when metrics plugins are not provided.

Suggested fix
-	if err := controller.metricsPluginMgr.InitPlugins(p.MetricsVolumePlugins, nil /* prober */, controller); err != nil {
+	metricsPlugins := p.MetricsVolumePlugins
+	if len(metricsPlugins) == 0 {
+		metricsPlugins = p.VolumePlugins
+	}
+	if err := controller.metricsPluginMgr.InitPlugins(metricsPlugins, nil /* prober */, controller); err != nil {
 		return nil, fmt.Errorf("could not initialize metrics volume plugins for PersistentVolume Controller: %w", err)
 	}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if err := controller.metricsPluginMgr.InitPlugins(p.MetricsVolumePlugins, nil /* prober */, controller); err != nil {
return nil, fmt.Errorf("could not initialize metrics volume plugins for PersistentVolume Controller: %w", err)
}
metricsPlugins := p.MetricsVolumePlugins
if len(metricsPlugins) == 0 {
metricsPlugins = p.VolumePlugins
}
if err := controller.metricsPluginMgr.InitPlugins(metricsPlugins, nil /* prober */, controller); err != nil {
return nil, fmt.Errorf("could not initialize metrics volume plugins for PersistentVolume Controller: %w", err)
}
🤖 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 `@pkg/controller/volume/persistentvolume/pv_controller_base.go` around lines
103 - 105, If P.MetricsVolumePlugins is nil/empty, fall back to P.VolumePlugins
before calling controller.metricsPluginMgr.InitPlugins so existing callers that
omit metrics plugins keep previous behavior; update the call site that currently
passes P.MetricsVolumePlugins to use a local variable (e.g., metricsPlugins :=
P.MetricsVolumePlugins; if len(metricsPlugins) == 0 { metricsPlugins =
P.VolumePlugins }) and then call
controller.metricsPluginMgr.InitPlugins(metricsPlugins, nil, controller) to
preserve backward compatibility (symbols to locate: P.MetricsVolumePlugins,
P.VolumePlugins, controller.metricsPluginMgr.InitPlugins in
pv_controller_base.go).

@openshift-ci

openshift-ci Bot commented Jun 1, 2026

Copy link
Copy Markdown

@dfajmon: 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-aws-ovn-techpreview-serial-2of2 1667c42 link false /test e2e-aws-ovn-techpreview-serial-2of2
ci/prow/e2e-aws-ovn-fips 1667c42 link true /test e2e-aws-ovn-fips
ci/prow/e2e-aws-ovn-serial-1of2 1667c42 link true /test e2e-aws-ovn-serial-1of2
ci/prow/e2e-aws-ovn-techpreview-serial-1of2 1667c42 link false /test e2e-aws-ovn-techpreview-serial-1of2
ci/prow/verify 1667c42 link true /test verify
ci/prow/e2e-aws-ovn-cgroupsv2 1667c42 link true /test e2e-aws-ovn-cgroupsv2
ci/prow/e2e-aws-ovn-crun 1667c42 link true /test e2e-aws-ovn-crun
ci/prow/e2e-aws-ovn-runc 1667c42 link false /test e2e-aws-ovn-runc
ci/prow/e2e-aws-ovn-techpreview 1667c42 link false /test e2e-aws-ovn-techpreview
ci/prow/e2e-gcp 1667c42 link true /test e2e-gcp
ci/prow/e2e-aws-ovn-serial-2of2 1667c42 link true /test e2e-aws-ovn-serial-2of2

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

backports/unvalidated-commits Indicates that not all commits come to merged upstream PRs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants