Skip to content

OCPBUGS-84330: Ensure lvdl update#615

Open
gnufied wants to merge 1 commit intoopenshift:mainfrom
gnufied:ensure-lvdl-update
Open

OCPBUGS-84330: Ensure lvdl update#615
gnufied wants to merge 1 commit intoopenshift:mainfrom
gnufied:ensure-lvdl-update

Conversation

@gnufied
Copy link
Copy Markdown
Member

@gnufied gnufied commented Apr 24, 2026

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

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of symlink status updates to proceed even when policies prevent actual symlink repair.
    • Enhanced error reporting with more specific context when policy mismatches occur.
  • Tests

    • Added validation that symlink status gets updated correctly in policy-restricted scenarios.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 24, 2026

Walkthrough

This PR introduces a new UpdateDeviceLinks helper method and a typed error PolicyNotPreferredError in the common package. Two reconcilers (LV and LVSet) are refactored to use shared DeviceLinkHandler instances and enhanced to handle the new error type by attempting LVDL status updates even when symlink policy prevents repairs.

Changes

Cohort / File(s) Summary
Common Package Enhancements
pkg/common/device_link_handler.go, pkg/common/pv_link_cache.go
Added UpdateDeviceLinks helper method for symlink status recomputation with PreferredLinkTarget change tracking. Added typed PolicyNotPreferredError to provide richer context when policy validation fails.
Test Updates
pkg/common/pv_link_cache_test.go
Updated single test assertion to expect new error message for policy-mismatch scenario.
LV Reconciler
pkg/diskmaker/controllers/lv/reconcile.go, pkg/diskmaker/controllers/lv/reconcile_test.go
Initialized shared deviceLinkHandler field. Refactored processRejectedDevicesForDeviceLinks to use shared handler. Enhanced error handling to detect PolicyNotPreferredError and call UpdateDeviceLinks for preferred target updates. Test coverage now validates target updates occur even under DeviceLinkPolicyNone.
LVSet Reconciler
pkg/diskmaker/controllers/lvset/reconcile.go, pkg/diskmaker/controllers/lvset/reconcile_test.go
Applied identical pattern: shared deviceLinkHandler initialization and field addition. Refactored both processRejectedDevicesForDeviceLinks and processNewSymlink to use shared handler and detect/handle PolicyNotPreferredError with UpdateDeviceLinks calls. Test coverage expanded to verify preferred/valid target updates under DeviceLinkPolicyNone.

Sequence Diagram

sequenceDiagram
    actor Reconciler as LV/LVSet Reconciler
    participant DLH as DeviceLinkHandler
    participant Cache as PV Link Cache
    participant Client as API Client
    
    Reconciler->>DLH: UpdateDeviceLinks(ctx, existing LVDL, blockDevice, currentSymlink)
    DLH->>DLH: Deep-copy LVDL
    DLH->>DLH: setStatusSymlinks(symlink paths)
    alt Symlink computation error
        DLH-->>Reconciler: error
    else Success
        DLH->>DLH: Check PreferredLinkTarget diff
        alt Status unchanged
            DLH-->>Reconciler: LVDL unchanged
        else Status changed
            alt PreferredLinkTarget changed
                DLH->>DLH: Resolve owner object
                DLH->>DLH: Record PreferredSymlinkChanged event
            end
            DLH->>Client: Status().Update(LVDL)
            alt Update succeeds
                Client-->>DLH: Updated object
                DLH->>Cache: Update cache entry
                DLH-->>Reconciler: Updated LVDL, nil error
            else Update fails
                Client-->>DLH: error
                DLH-->>Reconciler: original LVDL, error
            end
        end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 11 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (11 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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 test names in modified test files are static string literals defined in t.Run() calls with no dynamic content.
Test Structure And Quality ✅ Passed Tests properly use Ginkgo patterns with BeforeEach setup blocks, clear single responsibilities, and follow established codebase conventions for assertions and resource handling.
Microshift Test Compatibility ✅ Passed PR modifies only unit tests using Go testing framework, not Ginkgo e2e tests. MicroShift compatibility check is only applicable to new Ginkgo e2e tests.
Single Node Openshift (Sno) Test Compatibility ✅ Passed Pull request contains only standard Go unit tests using testing package, not Ginkgo e2e tests. No Ginkgo patterns detected.
Topology-Aware Scheduling Compatibility ✅ Passed Changes modify controller logic and device link handlers without introducing pod scheduling constraints or topology-dependent assumptions.
Ote Binary Stdout Contract ✅ Passed Modified files contain no process-level code (main(), init(), TestMain(), BeforeSuite(), AfterSuite(), SynchronizedBeforeSuite(), RunSpecs() setup, or top-level var/const initializers) that writes to stdout, therefore no OTE Binary Stdout Contract violations detected.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed No new Ginkgo e2e tests found. Test files use standard Go testing framework, not Ginkgo.
Title check ✅ Passed The title clearly indicates the main objective of updating LVDL (LocalVolumeDeviceLink) objects, which is directly supported by the changeset that refactors device link handling and introduces proper status updates.

✏️ Tip: You can configure your own custom pre-merge checks in the 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.

@openshift-ci openshift-ci Bot requested review from jsafrane and mpatlasov April 24, 2026 16:25
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Apr 24, 2026

[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 Apr 24, 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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@pkg/common/device_link_handler.go`:
- Around line 166-175: The code currently logs and emits the
"PreferredSymlinkChanged" event before persisting the status update; change the
flow so that you call dl.client.Status().Update(ctx, copyToUpdate) first, check
err == nil, then call dl.recorder.Eventf(ownerObj, corev1.EventTypeNormal,
"PreferredSymlinkChanged", infoUpdate) and
dl.cacheWriter.AddOrUpdateLVDL(copyToUpdate). Locate the block that constructs
infoUpdate using existing.Status.PreferredLinkTarget and
copyToUpdate.Status.PreferredLinkTarget and move the Eventf invocation to the
success branch after dl.client.Status().Update; apply the same change to the
other analogous block that also emits the event (the second occurrence in the
file).

In `@pkg/diskmaker/controllers/lv/reconcile.go`:
- Around line 506-513: The code calls r.deviceLinkHandler.UpdateDeviceLinks(ctx,
lvdl, deviceLocation.BlockDevice, deviceLocation.UserProvidedPath) after
findDeviceByID failed, which overwrites lvdl.Status.CurrentLinkTarget with a
broken user path; change the call so UpdateDeviceLinks is not given the missing
deviceLocation.UserProvidedPath as the currentSymlink (pass an empty string or
nil-equivalent instead) so CurrentLinkTarget remains the existing live target in
lvdl; update the call site referencing UpdateDeviceLinks, lvdl, and
deviceLocation.UserProvidedPath accordingly and ensure any downstream logic
still reads lvdl.Status.CurrentLinkTarget.
🪄 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: 58993d56-8bda-4521-b2d4-cd9f9dfa90ac

📥 Commits

Reviewing files that changed from the base of the PR and between 323a12a and 8e54875.

📒 Files selected for processing (8)
  • pkg/common/device_link_handler.go
  • pkg/common/pv_link_cache.go
  • pkg/common/pv_link_cache_test.go
  • pkg/diskmaker/controllers/lv/reconcile.go
  • pkg/diskmaker/controllers/lv/reconcile_test.go
  • pkg/diskmaker/controllers/lvset/reconcile.go
  • pkg/internal/diskutil.go
  • pkg/internal/diskutil_test.go

Comment thread pkg/common/device_link_handler.go
Comment thread pkg/diskmaker/controllers/lv/reconcile.go Outdated
@gnufied gnufied force-pushed the ensure-lvdl-update branch from 8e54875 to c3405ea Compare April 24, 2026 20:50
@gnufied gnufied changed the title Ensure lvdl update OCPBUGS-84330: Ensure lvdl update Apr 24, 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 Apr 24, 2026
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

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

  • expected the bug to target the "5.0.0" version, but no target version was 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.

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-84330

Summary by CodeRabbit

  • Bug Fixes

  • Improved handling of symlink status updates to proceed even when policies prevent actual symlink repair.

  • Enhanced error reporting with more specific context when policy mismatches occur.

  • Tests

  • Added validation that symlink status gets updated correctly in policy-restricted scenarios.

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.

@openshift-ci-robot openshift-ci-robot added the jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. label Apr 24, 2026
@gnufied
Copy link
Copy Markdown
Member Author

gnufied commented Apr 24, 2026

/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 Apr 24, 2026
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

@gnufied: This pull request references Jira Issue OCPBUGS-84330, 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 ASSIGNED, 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.

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Apr 24, 2026

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

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants