Skip to content

OCPBUGS-98984: Implement opt in for reclaim disk#641

Open
gnufied wants to merge 4 commits into
openshift:mainfrom
gnufied:implement-opt-in-for-reclaim-disk
Open

OCPBUGS-98984: Implement opt in for reclaim disk#641
gnufied wants to merge 4 commits into
openshift:mainfrom
gnufied:implement-opt-in-for-reclaim-disk

Conversation

@gnufied

@gnufied gnufied commented Jul 13, 2026

Copy link
Copy Markdown
Member

Fixes https://redhat.atlassian.net/browse/OCPBUGS-98984

Summary by CodeRabbit

  • Bug Fixes

    • Improved “last resort” recovery of PV/device symlinks when expected symlinks are missing or stale, with more precise matching against the preferred link target.
    • Ensure symlink parent directories are created before attempting atomic symlink recreation.
    • Avoid changing symlinks/LVDL state when the target PersistentVolume is in VolumeReleased.
  • Tests

    • Added new e2e coverage for symlink restoration after wipe (with and without filesystem signatures), including host-side wipe/restore verification.
    • Expanded unit/e2e symlink mismatch and recovery test scenarios with stricter validation paths.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Walkthrough

The change makes symlink mismatch detection account for missing on-disk links, ensures recreation directories exist, updates PV recovery checks, wires the path through reconcilers, and adds unit and end-to-end restoration coverage.

Changes

Symlink restoration

Layer / File(s) Summary
Link detection and PV recovery
pkg/common/device_link_handler.go, pkg/common/current_block_device_info.go
Mismatch checks inspect the supplied on-disk symlink, recreation creates its parent directory, and PV recovery uses Readlink while handling missing or stale links.
Reconciler integration and validation
pkg/common/provisioner_utils.go, pkg/diskmaker/controllers/..., pkg/common/*_test.go
Reconciliation paths pass symlink paths into mismatch detection, handle mismatch errors, skip released PV updates, and test matching, missing, stale, and unreadable links.
Wipe-restoration test flow
test/e2e/localvolume_test.go, test/e2e/localvolumeset_test.go, test/e2e/symlink_check.go
E2E tests wipe host symlinks through node Jobs and verify preferred-target restoration for devices with and without filesystem signatures.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant E2ETest
  participant WipeJob
  participant NodeFilesystem
  participant LVDL
  E2ETest->>WipeJob: wipe /mnt/local-storage symlinks
  WipeJob->>NodeFilesystem: remove host symlinks
  LVDL->>NodeFilesystem: restore preferred target
  E2ETest->>NodeFilesystem: verify restored symlink
  E2ETest->>LVDL: verify target convergence
Loading

Possibly related PRs

Suggested reviewers: mpatlasov, rhrmo


Important

Pre-merge checks failed

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

❌ Failed checks (1 error, 3 warnings)

Check name Status Explanation Resolution
No-Sensitive-Data-In-Logs ❌ Error New e2e and controller logs print node hostnames and symlink paths/targets, which can expose internal host info. Redact or omit hostnames and full paths from these log lines; prefer stable IDs or hashed/redacted values, especially in test/e2e/symlink_check.go and mismatch error logs.
Docstring Coverage ⚠️ Warning Docstring coverage is 45.45% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Microshift Test Compatibility ⚠️ Warning New e2e contexts use local.storage.openshift.io CRDs and require >=3 worker nodes, with no MicroShift skip/apigroup guard. Add a MicroShift guard or skip label, or exclude these tests from MicroShift CI. They assume multi-node/AWS storage, so they should not run on single-node MicroShift.
Single Node Openshift (Sno) Test Compatibility ⚠️ Warning Added e2e contexts live in suites that require >=3 worker nodes and have no SNO skip/guard, so they won’t run on SNO. Add a [Skipped:SingleReplicaTopology] label or a runtime single-node skip check to these e2e contexts, or move them behind an SNO-excluded suite.
✅ Passed checks (11 passed)
Check name Status Explanation
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 new/edited test titles are static strings; no Ginkgo spec names include dynamic values, node/namespace names, UUIDs, or timestamps.
Test Structure And Quality ✅ Passed The new Ginkgo specs are narrowly scoped, use DeferCleanup/cleanup helpers for cluster resources, and cluster waits have explicit timeouts.
Topology-Aware Scheduling Compatibility ✅ Passed No new pod scheduling constraints were added; the modified controllers only change symlink/PV reconciliation, and the e2e job helpers are test-only.
Ote Binary Stdout Contract ✅ Passed PR adds no stdout writes in main/init/TestMain/BeforeSuite/setup; new echo/logging is only inside test helpers/jobs, not process-level code.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed The new e2e contexts only use node jobs and cluster APIs; I գտ no IPv4 literals, IPv6-host formatting issues, or public-internet dependencies.
No-Weak-Crypto ✅ Passed Scanned all 9 touched files; no MD5/SHA1/DES/RC4/3DES/Blowfish/ECB usage, no crypto imports, and no secret/token comparisons were found.
Container-Privileges ✅ Passed No changed file in main...HEAD adds privileged/hostPID/hostNetwork/hostIPC/allowPrivilegeEscalation/SYS_ADMIN settings; new e2e jobs reuse an unchanged helper.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the PR’s main goal: adding opt-in behavior for reclaiming disks.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@openshift-ci openshift-ci Bot requested review from mpatlasov and rhrmo July 13, 2026 04:28
@openshift-ci

openshift-ci Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gnufied

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 Jul 13, 2026

@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: 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 `@pkg/common/current_block_device_info.go`:
- Around line 95-98: Update the symlink handling around internal.Readlink so
recovery proceeds only when the path is missing (os.IsNotExist(err)) or Readlink
succeeds with an alternate target; return a wrapped error for permission, I/O,
non-symlink, and other failures. Preserve the existing error when the target
equals currentLinkTarget, and do not ignore any Readlink error.

In `@pkg/common/device_link_handler.go`:
- Around line 467-472: The symlink validation around os.Lstat in the device-link
handler ignores non-ENOENT failures. Update this block to return the existing
error type or propagate the Lstat error when symlinkPath is set and the call
fails for any reason other than os.IsNotExist(err), while preserving the current
missing-symlink log and true result for ENOENT.

In `@pkg/common/provisioner_utils.go`:
- Line 129: Move the existing-PV lookup and VolumeReleased check before the
HasMismatchingSymlink/RecreateSymlinkIfNeeded recovery flow in the relevant
provisioner utility function. Ensure released volumes return ErrTryAgain without
recreating the directory or symlink or updating LVDL status, while non-released
volumes retain the current recovery behavior.

In `@test/e2e/symlink_check.go`:
- Around line 439-444: Add a descriptive failure message to the Job completion
assertion in the Eventually chain, including the check job, node, and path
details available in the surrounding test context. Keep the existing completion
condition and polling behavior unchanged.
- Around line 370-399: Update newWipeLocalStorageJob to remove the “|| true”
suppression from the symlink deletion command so find failures cause the job to
fail. Before running the wipe, assert that the target PV symlink exists, using
the test’s existing PV-link identification or validation mechanism, while
preserving the current job flow and failure propagation.
🪄 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: 8d21efd3-85f6-4885-a7fd-c0a0b305ffc9

📥 Commits

Reviewing files that changed from the base of the PR and between b4a98b6 and 560ecf2.

📒 Files selected for processing (10)
  • pkg/common/current_block_device_info.go
  • pkg/common/device_link_handler.go
  • pkg/common/device_link_handler_test.go
  • pkg/common/provisioner_utils.go
  • pkg/common/pv_link_cache_test.go
  • pkg/diskmaker/controllers/lv/reconcile.go
  • pkg/diskmaker/controllers/lvset/reconcile.go
  • test/e2e/localvolume_test.go
  • test/e2e/localvolumeset_test.go
  • test/e2e/symlink_check.go

Comment thread pkg/common/current_block_device_info.go Outdated
Comment thread pkg/common/device_link_handler.go
Comment thread pkg/common/provisioner_utils.go Outdated
Comment thread test/e2e/symlink_check.go Outdated
Comment thread test/e2e/symlink_check.go Outdated
@gnufied gnufied force-pushed the implement-opt-in-for-reclaim-disk branch from dec0980 to c3fff76 Compare July 13, 2026 04:39
@gnufied

gnufied commented Jul 13, 2026

Copy link
Copy Markdown
Member Author

/retest

1 similar comment
@gnufied

gnufied commented Jul 13, 2026

Copy link
Copy Markdown
Member Author

/retest

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

🧹 Nitpick comments (1)
pkg/diskmaker/controllers/lv/create_pv_test.go (1)

663-676: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low value

Remove the unused filesystem stubs. SyncPVAndLVDL returns on the Released-PV path before HasMismatchingSymlink / RecreateSymlinkIfNeeded, so FilePathGlob and FilePathEvalSymlinks never affect this test case.

🤖 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/diskmaker/controllers/lv/create_pv_test.go` around lines 663 - 676,
Remove the unused FilePathGlob and FilePathEvalSymLinks stubs from the
diskmakertest.WithInternalMocks block in the SyncPVAndLVDL test, along with any
now-unneeded imports or setup they require; preserve the test’s Released-PV
behavior.
🤖 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 `@pkg/diskmaker/controllers/lv/create_pv_test.go`:
- Around line 663-676: Remove the unused FilePathGlob and FilePathEvalSymLinks
stubs from the diskmakertest.WithInternalMocks block in the SyncPVAndLVDL test,
along with any now-unneeded imports or setup they require; preserve the test’s
Released-PV behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 3627e0d5-404b-4bbb-9156-ce8f994fa5ec

📥 Commits

Reviewing files that changed from the base of the PR and between c3fff76 and 07a8638.

📒 Files selected for processing (9)
  • pkg/common/current_block_device_info.go
  • pkg/common/device_link_handler.go
  • pkg/common/device_link_handler_test.go
  • pkg/common/provisioner_utils.go
  • pkg/common/pv_link_cache_test.go
  • pkg/diskmaker/controllers/lv/create_pv_test.go
  • pkg/diskmaker/controllers/lv/reconcile.go
  • pkg/diskmaker/controllers/lvset/reconcile.go
  • test/e2e/symlink_check.go
🚧 Files skipped from review as they are similar to previous changes (7)
  • pkg/diskmaker/controllers/lv/reconcile.go
  • pkg/diskmaker/controllers/lvset/reconcile.go
  • pkg/common/device_link_handler_test.go
  • pkg/common/provisioner_utils.go
  • pkg/common/current_block_device_info.go
  • pkg/common/device_link_handler.go
  • test/e2e/symlink_check.go

@openshift-ci

openshift-ci Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

@gnufied: 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 gnufied changed the title Implement opt in for reclaim disk OCPBUGS-98984: Implement opt in for reclaim disk Jul 16, 2026
@openshift-ci-robot openshift-ci-robot added jira/severity-important Referenced Jira bug's severity is important for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Jul 16, 2026
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@gnufied: This pull request references Jira Issue OCPBUGS-98984, which is invalid:

  • expected the bug to target either version "5.0." or "openshift-5.0.", but it targets "4.23" instead

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

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

Details

In response to this:

Fixes https://redhat.atlassian.net/browse/OCPBUGS-98984

Summary by CodeRabbit

  • Bug Fixes

  • Improved “last resort” recovery of PV/device symlinks when expected symlinks are missing or stale, with more precise matching against the preferred link target.

  • Ensure symlink parent directories are created before attempting atomic symlink recreation.

  • Avoid changing symlinks/LVDL state when the target PersistentVolume is in VolumeReleased.

  • Tests

  • Added new e2e coverage for symlink restoration after wipe (with and without filesystem signatures), including host-side wipe/restore verification.

  • Expanded unit/e2e symlink mismatch and recovery test scenarios with stricter validation paths.

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.

@gnufied

gnufied commented Jul 16, 2026

Copy link
Copy Markdown
Member Author

/jira refresh

@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@gnufied: This pull request references Jira Issue OCPBUGS-98984, which is invalid:

  • expected the bug to target only the "5.0.0" version, but multiple target versions were set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

Details

In response to this:

/jira refresh

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.

@gnufied

gnufied commented Jul 16, 2026

Copy link
Copy Markdown
Member Author

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Jul 16, 2026
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

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

In response to this:

/jira refresh

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.

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-important Referenced Jira bug's severity is important 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants