Skip to content

Automate OCP-89594-Verify LVMCluster deviceDiscoveryPolicy is configu…#2758

Open
mmakwana30 wants to merge 1 commit into
openshift:mainfrom
mmakwana30:OCP-89594
Open

Automate OCP-89594-Verify LVMCluster deviceDiscoveryPolicy is configu…#2758
mmakwana30 wants to merge 1 commit into
openshift:mainfrom
mmakwana30:OCP-89594

Conversation

@mmakwana30

@mmakwana30 mmakwana30 commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

…rable

Summary by CodeRabbit

  • Tests
    • Improved validation of device discovery policy transitions across Static → Dynamic → Static cycles.
    • Added assertions that device inventory/volume group devices remain preserved when switching policies.
    • Enhanced lifecycle coverage with an intermediate delete/verification step to ensure cluster resources and VG removal are fully cleaned up.
    • Relaxed excluded-device reason validation to require a non-empty reason rather than matching specific text.
    • Updated test template configuration for device selection behavior (including force-wipe/data-destroy settings).

@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

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

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: 140c6022-87bb-4ab9-8765-38c4d9b946d3

📥 Commits

Reviewing files that changed from the base of the PR and between d4cfdc8 and c298969.

📒 Files selected for processing (2)
  • test/integration/qe_tests/lvms.go
  • test/integration/qe_tests/testdata/lvmcluster-devicediscovery-template.yaml
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/integration/qe_tests/lvms.go

Walkthrough

The deviceDiscoveryPolicy integration test now creates the initial LVMCluster from a manifest, verifies cleanup after deletion, validates Static → Dynamic → Static runtime transitions, and checks VG device preservation throughout.

Changes

Device Discovery Policy Validation

Layer / File(s) Summary
Cluster setup and cleanup
test/integration/qe_tests/lvms.go, test/integration/qe_tests/testdata/lvmcluster-devicediscovery-template.yaml
The test uses lvmClusterManifest, enables forced device wiping in the template, requires non-empty excluded-device reasons, and verifies VG removal after cluster deletion.
Runtime policy transition checks
test/integration/qe_tests/lvms.go
Runtime Static and Dynamic statuses are asserted across policy changes, VG device counts are preserved, and cleanup/restoration steps are renumbered.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: qjkee, jerpeter1

🚥 Pre-merge checks | ✅ 14 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (14 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: automating verification that LVMCluster deviceDiscoveryPolicy is configurable.
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 PASS: The changed Ginkgo test title is a static string; no dynamic formatting or generated names appear in the modified test file.
Test Structure And Quality ✅ Passed The deviceDiscoveryPolicy It block uses BeforeEach/AfterEach plus defers for cleanup, and all cluster waits have explicit timeouts.
Microshift Test Compatibility ✅ Passed The added test only uses Kubernetes/LVMS CRDs, and the template helper strips the OpenShift Template wrapper, so no MicroShift-unsupported OpenShift APIs/features were found.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The new test only enumerates worker nodes/disks and never requires >1 node, cross-node scheduling, or failover, so it’s SNO-compatible.
Topology-Aware Scheduling Compatibility ✅ Passed PASS: The PR only changes LVMS integration tests and a test LVMCluster template; it adds deviceSelector.forceWipeDevicesAndDestroyAllData, with no node selectors, affinities, tolerations, or replic...
Ote Binary Stdout Contract ✅ Passed The diff only alters It-block test logic and YAML; no main/init/TestMain/BeforeSuite stdout writes were added, and the new log call is inside the test body.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed The new Ginkgo test only uses cluster-internal oc/API calls and disk paths; no hardcoded IPv4, IPv4-only parsing, or public internet access was found.
No-Weak-Crypto ✅ Passed Touched files only adjust LVMCluster test flow/YAML; no MD5/SHA1/DES/RC4/3DES/Blowfish, custom crypto, or secret comparisons found.
Container-Privileges ✅ Passed No touched manifest adds privileged, hostPID/Network/IPC, SYS_ADMIN, or allowPrivilegeEscalation; the diff only adds deviceSelector and test logic.
No-Sensitive-Data-In-Logs ✅ Passed New logs only emit LVMS status/warnings; no passwords, tokens, PII, hostnames, or customer data are logged in the changed lines.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.44.1)
test/integration/qe_tests/lvms.go

ast-grep timed out on this file


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.

@openshift-ci openshift-ci Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 25, 2026
@openshift-ci
openshift-ci Bot requested review from jerpeter1 and qJkee June 25, 2026 11:45
@openshift-ci

openshift-ci Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
test/integration/qe_tests/lvms_utils.go (1)

803-817: 🗄️ Data Integrity & Integration | 🟠 Major

Sanitize exported JSON fields before applying

Raw server-side fields (specifically status, uid, resourceVersion, and managedFields) passed in the manifest cause conflicts or validation errors, even with the fallback client-side apply. The input JSON must be stripped of these server-owned keys before execution.

🤖 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 `@test/integration/qe_tests/lvms_utils.go` around lines 803 - 817, The
createLVMClusterFromManifest flow still passes exported JSON with server-owned
fields through both apply paths, so sanitize the manifest before calling oc
apply. In createLVMClusterFromManifest, strip status, uid, resourceVersion, and
managedFields from the input manifest first, then use the cleaned manifest for
both the server-side and fallback client-side apply commands so the function no
longer feeds invalid server-managed data to oc.
🧹 Nitpick comments (1)
test/integration/qe_tests/lvms_utils.go (1)

806-812: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Bound both oc apply calls with a timeout.

Use exec.CommandContext for the SSA attempt and fallback so a stuck CLI/API call does not hang the serial disruptive suite.

As per path instructions, **/*.go: context.Context for cancellation and timeouts.

🤖 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 `@test/integration/qe_tests/lvms_utils.go` around lines 806 - 812, Both oc
apply invocations in the apply-manifest flow are unbounded and can hang the
serial suite; update the logic around the existing exec.Command calls to use
exec.CommandContext with a context that has a timeout for both the server-side
apply attempt and the fallback apply. Make sure the context is created in the
surrounding helper before calling the apply commands, and that both command
paths in this function use the same cancellation/timeout handling so a stuck CLI
or API call cannot block the run.

Source: Path instructions

🤖 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 `@test/integration/qe_tests/lvms.go`:
- Line 564: Handle the restore calls in the cleanup defers so their errors are
not silently discarded; update each createLVMClusterFromManifest(...) use in the
affected deferred cleanup blocks to capture the returned error and either log it
with context or fail cleanup explicitly, following the same pattern across the
repeated restore sites in qe_tests/lvms.go.
- Around line 5859-5866: The VG cleanup check in the eventual assertion
currently treats any `oc get` error as success, which can mask transient
failures. Update the retry logic around the `exec.Command("oc", "get",
"lvmvolumegroup", ...)` call so that command errors are logged and return false
to keep retrying, and only return true when the `CombinedOutput` succeeds and
the trimmed output is actually empty. Keep the behavior localized to the
`Eventually` block in `lvms.go`.
- Line 5832: The test setup for createLVMClusterFromManifest should register
failure-path cleanup for test-lvmcluster-89594 as soon as newLVMClusterName and
deviceClassName are initialized. Add an immediate defer in this setup block to
delete the temporary LVMCluster on failure before any later assertions run, so
the existing restore defer in the surrounding test does not leave the temporary
resource behind.

---

Outside diff comments:
In `@test/integration/qe_tests/lvms_utils.go`:
- Around line 803-817: The createLVMClusterFromManifest flow still passes
exported JSON with server-owned fields through both apply paths, so sanitize the
manifest before calling oc apply. In createLVMClusterFromManifest, strip status,
uid, resourceVersion, and managedFields from the input manifest first, then use
the cleaned manifest for both the server-side and fallback client-side apply
commands so the function no longer feeds invalid server-managed data to oc.

---

Nitpick comments:
In `@test/integration/qe_tests/lvms_utils.go`:
- Around line 806-812: Both oc apply invocations in the apply-manifest flow are
unbounded and can hang the serial suite; update the logic around the existing
exec.Command calls to use exec.CommandContext with a context that has a timeout
for both the server-side apply attempt and the fallback apply. Make sure the
context is created in the surrounding helper before calling the apply commands,
and that both command paths in this function use the same cancellation/timeout
handling so a stuck CLI or API call cannot block the run.
🪄 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: 0e870db2-2132-482f-9ae3-da9a4672d852

📥 Commits

Reviewing files that changed from the base of the PR and between bdda898 and 417f81f.

📒 Files selected for processing (2)
  • test/integration/qe_tests/lvms.go
  • test/integration/qe_tests/lvms_utils.go

Comment thread test/integration/qe_tests/lvms.go Outdated
Comment thread test/integration/qe_tests/lvms.go Outdated
Comment thread test/integration/qe_tests/lvms.go
@codecov-commenter

codecov-commenter commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 54.62%. Comparing base (bdda898) to head (c298969).
⚠️ Report is 101 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2758      +/-   ##
==========================================
+ Coverage   53.03%   54.62%   +1.58%     
==========================================
  Files          53       54       +1     
  Lines        4033     4225     +192     
==========================================
+ Hits         2139     2308     +169     
- Misses       1723     1734      +11     
- Partials      171      183      +12     

see 10 files with indirect coverage changes

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

@coderabbitai coderabbitai Bot added the ready-for-human-review Indicates a PR has been reviewed by automated tools and is ready for human review label Jun 25, 2026
@mmakwana30
mmakwana30 force-pushed the OCP-89594 branch 2 times, most recently from 7b83924 to 8d84f64 Compare June 26, 2026 10:28
@openshift-ci openshift-ci Bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 26, 2026
@mmakwana30

Copy link
Copy Markdown
Contributor Author

/test e2e-aws-single-node

1 similar comment
@mmakwana30

Copy link
Copy Markdown
Contributor Author

/test e2e-aws-single-node

o.Expect(err).NotTo(o.HaveOccurred())
defer func() {
deleteLVMClusterSafely(newLVMClusterName, lvmsNamespace, deviceClassName)
}()

@kasturinarra kasturinarra Jul 8, 2026

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.

we need the defer here, any reason you removed this ?

  1. Step 4 creates test-lvmcluster-89594
  2. The defer that would clean it up is now gone
  3. If steps 5-8 fail (assertion, timeout, anything), the test panics out
  4. The outer defer at step 3 (lines 5800-5805) tries to restore the original LVMCluster — but LVMS only allows one LVMCluster. The restore fails because test-lvmcluster-89594 still exists
  5. Result: the test cluster is leaked, the original LVMCluster is not restored, and all subsequent tests in this file fail

Comment thread test/integration/qe_tests/lvms.go Outdated
excludedReasons, err := getExcludedDeviceReasons(deviceClassName)
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(excludedReasons).To(o.ContainElement(o.ContainSubstring("excluded")))
o.Expect(len(excludedReasons)).To(o.BeNumerically(">", 0), "Excluded devices should have reasons")

@kasturinarra kasturinarra Jul 8, 2026

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.

Step 7 already asserts len(excludedDevices) > 0. Step 8's purpose is to verify that excluded devices have clear status messages (per the g.By text). The new assertion only checks the
list is non-empty — it no longer validates the content of the reason strings at all. This makes step 8 a near-duplicate of step 7 with no additional value.

Either restore content validation or pick a more appropriate substring if "excluded" was too brittle:
o.Expect(excludedReasons).To(o.ContainElement(o.Not(o.BeEmpty())), "Excluded devices should have non-empty reason strings")

@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: 3

🤖 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 `@test/integration/qe_tests/lvms.go`:
- Around line 5912-5916: Update the VG preservation assertions around
getVGDevices in the Dynamic transition and the additionally referenced
transition block to compare canonicalized device identities, not just lengths.
Capture and canonicalize the original and post-transition device lists, then
assert the lists contain the same devices while retaining the existing error
checks and preservation expectations.
- Around line 5862-5867: Update the exec.Command calls in the Eventually
callbacks around the lvmvolumegroup checks and the additional locations to use
context-aware execution with a short per-invocation timeout. Create a
context.Context and cancel function for each command, pass it to
exec.CommandContext, and ensure cancellation occurs after the command completes
or times out so CombinedOutput cannot block indefinitely.
- Around line 5858-5870: The verification after deleteLVMClusterSafely must
confirm physical VG removal from every worker disk, not merely that
LVMVolumeGroup resources are gone. Replace or extend the oc get lvmvolumegroup
polling with node-side LVM state checks for all relevant workers and devices,
and wait until no VG remains before proceeding to recreate the cluster.
🪄 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: 2c3a85ac-302d-4f3f-8d93-11a254f5b1fd

📥 Commits

Reviewing files that changed from the base of the PR and between 7b83924 and d4cfdc8.

📒 Files selected for processing (1)
  • test/integration/qe_tests/lvms.go

Comment thread test/integration/qe_tests/lvms.go
Comment thread test/integration/qe_tests/lvms.go
Comment thread test/integration/qe_tests/lvms.go
@mmakwana30

Copy link
Copy Markdown
Contributor Author

/retest-required

@coderabbitai coderabbitai Bot removed the ready-for-human-review Indicates a PR has been reviewed by automated tools and is ready for human review label Jul 16, 2026
@openshift-ci

openshift-ci Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

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

@kasturinarra

Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants