Skip to content

OCPBUGS-52262: Allow filtering out devices by the device name#599

Open
tsmetana wants to merge 1 commit intoopenshift:mainfrom
tsmetana:ignore-rbd-devices
Open

OCPBUGS-52262: Allow filtering out devices by the device name#599
tsmetana wants to merge 1 commit intoopenshift:mainfrom
tsmetana:ignore-rbd-devices

Conversation

@tsmetana
Copy link
Copy Markdown
Member

This should fix the problem with LSO picking up (and corrupting) RBD devices on Virt clusters. The patch adds a new deviceExclusionSpec type that allows for filtering out devices based on device name pattern (e.g. rbd*, which should fix the referenced bug).

@openshift-ci-robot openshift-ci-robot added jira/severity-critical Referenced Jira bug's severity is critical for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. labels Mar 31, 2026
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

@tsmetana: This pull request references Jira Issue OCPBUGS-52262, 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 (4.22.0) matches configured target version for branch (4.22.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, POST)

No GitHub users were found matching the public email listed for the QA contact in Jira (wduan@redhat.com), skipping review request.

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

Details

In response to this:

This should fix the problem with LSO picking up (and corrupting) RBD devices on Virt clusters. The patch adds a new deviceExclusionSpec type that allows for filtering out devices based on device name pattern (e.g. rbd*, which should fix the referenced bug).

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
Copy link
Copy Markdown

coderabbitai Bot commented Mar 31, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ad0f97f2-b143-4859-afe1-598b2a0ffa75

📥 Commits

Reviewing files that changed from the base of the PR and between 922cf7e and 49c7283.

📒 Files selected for processing (7)
  • api/v1alpha1/localvolumeset_types.go
  • api/v1alpha1/zz_generated.deepcopy.go
  • config/manifests/stable/local.storage.openshift.io_localvolumesets.yaml
  • pkg/diskmaker/controllers/lvset/device_age_test.go
  • pkg/diskmaker/controllers/lvset/matcher.go
  • pkg/diskmaker/controllers/lvset/matcher_test.go
  • pkg/diskmaker/controllers/lvset/reconcile.go
✅ Files skipped from review due to trivial changes (3)
  • pkg/diskmaker/controllers/lvset/matcher.go
  • pkg/diskmaker/controllers/lvset/reconcile.go
  • config/manifests/stable/local.storage.openshift.io_localvolumesets.yaml
🚧 Files skipped from review as they are similar to previous changes (4)
  • pkg/diskmaker/controllers/lvset/device_age_test.go
  • api/v1alpha1/localvolumeset_types.go
  • pkg/diskmaker/controllers/lvset/matcher_test.go
  • api/v1alpha1/zz_generated.deepcopy.go

Walkthrough

Added a DeviceExclusionSpec to the LocalVolumeSet API enabling glob-pattern device exclusion by kernel name, generated deepcopy methods, updated CRD schema, implemented exclusion matcher logic and tests, and integrated exclusion checks into the device reconciliation flow.

Changes

Cohort / File(s) Summary
API Type Definitions
api/v1alpha1/localvolumeset_types.go, api/v1alpha1/zz_generated.deepcopy.go
Added exported DeviceExclusionSpec with DeviceNameFilter []string and added DeviceExclusionSpec *DeviceExclusionSpec to LocalVolumeSetSpec. Generated deepcopy methods for the new type and updated LocalVolumeSetSpec.DeepCopyInto to copy the new field.
CRD Schema
config/manifests/stable/local.storage.openshift.io_localvolumesets.yaml
Added spec.deviceExclusionSpec object with deviceNameFilter ([]string, maxItems: 64) describing glob patterns for kernel-name-based device exclusion.
Exclusion Matcher Implementation
pkg/diskmaker/controllers/lvset/matcher.go, pkg/diskmaker/controllers/lvset/matcher_test.go
Introduced notInDeviceNameFilter matcher, new exclusionMap, and exclusion function using filepath.Match to evaluate DeviceExclusionSpec.DeviceNameFilter. Added error handling for invalid patterns and comprehensive unit tests (TestNotInDeviceNameFilter) covering nil/empty specs, matches, multi-patterns, wildcards, and pattern errors.
Reconciliation Integration
pkg/diskmaker/controllers/lvset/reconcile.go
Extended getValidDevices to run exclusion matchers (from exclusionMap) after inclusion checks; devices failing exclusion are skipped and errors are logged.
Test Infrastructure
pkg/diskmaker/controllers/lvset/device_age_test.go
Updated TestDeviceAge to save, clear, and restore the global exclusionMap during the test run alongside existing matcher maps.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

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

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@openshift-ci openshift-ci Bot requested review from dobsonj and rhrmo March 31, 2026 12:13
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Mar 31, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: tsmetana

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 Mar 31, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
pkg/diskmaker/controllers/lvset/reconcile.go (1)

351-351: Guard lvset before dereferencing exclusion spec in getValidDevices.

Line 351 dereferences lvset.Spec unconditionally. Extracting inclusion/exclusion specs once with an lvset != nil guard would make this helper robust and remove reliance on global-map test setup.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/diskmaker/controllers/lvset/reconcile.go` at line 351, In
getValidDevices, avoid unguarded dereference of lvset by first checking lvset !=
nil and extracting the inclusion/exclusion specs (e.g., DeviceInclusionSpec and
DeviceExclusionSpec) into local variables before using them; replace direct
references like lvset.Spec.DeviceExclusionSpec with the local variables and
short-circuit or return an appropriate default when lvset is nil so the function
no longer relies on a global-map test setup.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@pkg/diskmaker/controllers/lvset/reconcile.go`:
- Line 351: In getValidDevices, avoid unguarded dereference of lvset by first
checking lvset != nil and extracting the inclusion/exclusion specs (e.g.,
DeviceInclusionSpec and DeviceExclusionSpec) into local variables before using
them; replace direct references like lvset.Spec.DeviceExclusionSpec with the
local variables and short-circuit or return an appropriate default when lvset is
nil so the function no longer relies on a global-map test setup.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0ab34cfc-2eb6-45a5-b4fb-8667e33db345

📥 Commits

Reviewing files that changed from the base of the PR and between 846b94d and 922cf7e.

📒 Files selected for processing (7)
  • api/v1alpha1/localvolumeset_types.go
  • api/v1alpha1/zz_generated.deepcopy.go
  • config/manifests/stable/local.storage.openshift.io_localvolumesets.yaml
  • pkg/diskmaker/controllers/lvset/device_age_test.go
  • pkg/diskmaker/controllers/lvset/matcher.go
  • pkg/diskmaker/controllers/lvset/matcher_test.go
  • pkg/diskmaker/controllers/lvset/reconcile.go

Comment thread pkg/diskmaker/controllers/lvset/reconcile.go
// '*' matches any sequence of non-separator characters.
// Example: ["rbd*"] excludes all rbd0, rbd1, etc.
// +optional
DeviceNameFilter []string `json:"deviceNameFilter,omitempty"`
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.

Add maxitems validation please.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

OK. Hopefully this is fine.

@tsmetana tsmetana force-pushed the ignore-rbd-devices branch from 922cf7e to 49c7283 Compare April 8, 2026 08:29
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Apr 8, 2026

@tsmetana: 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.

@gnufied
Copy link
Copy Markdown
Member

gnufied commented Apr 13, 2026

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Apr 13, 2026
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/severity-critical Referenced Jira bug's severity is critical for the branch this PR is targeting. 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