Skip to content

feat: PVC-based shared disk device detection - #552

Merged
myakove merged 10 commits into
RedHatQE:mainfrom
MiriSafra:feat/pvc-based-shared-disk-detection
Jun 16, 2026
Merged

myakove merged 10 commits into
RedHatQE:mainfrom
MiriSafra:feat/pvc-based-shared-disk-detection

Conversation

@MiriSafra

@MiriSafra MiriSafra commented Jun 14, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Refactor shared disk device detection from source-side heuristic to
    destination-side PVC lookup
  • Find the shared disk by intersecting PVC references from both destination
    VMIs — no assumptions about controller layout or disk ordering
  • Per-VM device paths handle VMs with different disk counts correctly
  • More dynamic: reads what Forklift actually created rather than predicting
    from source config

Summary by CodeRabbit

  • Tests

    • Enhanced shared-disk migration verification to use administrative client context for more reliable validation.
  • Improvements

    • Improved shared-disk device and partition detection by resolving shared PVCs and device targets from each destination virtual machine’s runtime configuration, rather than relying on the source disk layout.
    • Updated verification flow to mount, remount, and flush buffers using per-VM device/partition information for more accurate shared-disk checks.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@coderabbitai

coderabbitai Bot commented Jun 14, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 86204264-8ee0-4243-b539-6d13e89da7e6

📥 Commits

Reviewing files that changed from the base of the PR and between 18ef74f and a71f79b.

📒 Files selected for processing (2)
  • tests/shared_disk/test_shared_disk_rhel_migration.py
  • utilities/shared_disk.py

Walkthrough

utilities/shared_disk.py replaces source-layout-based shared-disk device lookup with destination-aware helpers that inspect VMI volumes of migrated VMs to resolve per-VM /dev/vdX paths. verify_shared_disk_data gains an ocp_admin_client parameter, and the test fixture is updated to inject it.

Changes

Destination-aware shared-disk device resolution

Layer / File(s) Summary
Type checking imports for VMI and client support
utilities/shared_disk.py
Adds VirtualMachine import and TYPE_CHECKING-guarded DynamicClient type annotation for runtime type hints.
Destination VMI device path resolution helpers
utilities/shared_disk.py
Introduces _get_pvc_device_targets to extract each destination VM's PVC-to-device mappings from VMI volumeStatus with polling, and _get_shared_disk_devices to intersect both VMs' PVC lists, validate exactly one shared PVC exists, and return per-destination device paths. Replaces the prior source-layout-based resolver.
verify_shared_disk_data refactored for per-VM device paths
utilities/shared_disk.py
Adds ocp_admin_client: DynamicClient parameter; derives vm1_config/vm2_config and destination namespace from prepared_plan; calls _get_shared_disk_devices to resolve vm1_device and vm2_device; updates mount, write, read, and cache-flush steps to use per-VM partition variables (vm1_partition/vm2_partition) derived from those device paths.
Test fixture wiring
tests/shared_disk/test_shared_disk_rhel_migration.py
test_verify_shared_disk_data accepts ocp_admin_client as a pytest fixture parameter and forwards it to verify_shared_disk_data.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • RedHatQE/mtv-api-tests#538: Modifies utilities/shared_disk.py to dynamically determine the shared-disk /dev/vdX device path — directly related to the device resolution logic this PR replaces.

Suggested labels

verified

Suggested reviewers

  • myakove
  • solenoci
  • krcmarik
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: PVC-based shared disk device detection' accurately describes the core refactoring: shifting from source-side heuristic detection to destination-side PVC lookups.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

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

@redhat-qe-bot

Copy link
Copy Markdown

Report bugs in Issues

Welcome! 🎉

This pull request will be automatically processed with the following features:

🔄 Automatic Actions

  • Reviewer Assignment: Reviewers are automatically assigned based on the OWNERS file in the repository root
  • Size Labeling: PR size labels (XS, S, M, L, XL, XXL) are automatically applied based on changes
  • Issue Creation: Disabled for this repository
  • Branch Labeling: Branch-specific labels are applied to track the target branch
  • Auto-verification: Auto-verified users have their PRs automatically marked as verified
  • Labels: All label categories are enabled (default configuration)

📋 Available Commands

PR Status Management

  • /wip - Mark PR as work in progress (adds WIP: prefix to title)
  • /wip cancel - Remove work in progress status
  • /hold - Block PR merging (approvers only)
  • /hold cancel - Unblock PR merging
  • /verified - Mark PR as verified
  • /verified cancel - Remove verification status
  • /reprocess - Trigger complete PR workflow reprocessing (useful if webhook failed or configuration changed)
  • /regenerate-welcome - Regenerate this welcome message
  • /security-override - Set security check runs to pass (maintainers only)
  • /security-override cancel - Re-run security checks

Review & Approval

  • /lgtm - Approve changes (looks good to me)
  • /approve - Approve PR (approvers only)
  • /automerge - Enable automatic merging when all requirements are met (maintainers and approvers only)
  • /assign-reviewers - Assign reviewers based on OWNERS file
  • /assign-reviewer @username - Assign specific reviewer
  • /check-can-merge - Check if PR meets merge requirements

Testing & Validation

  • /retest tox - Run Python test suite with tox
  • /retest build-container - Rebuild and test container image
  • /retest conventional-title - Validate commit message format
  • /retest all - Run all available tests

Container Operations

  • /build-and-push-container - Build and push container image (tagged with PR number)
    • Supports additional build arguments: /build-and-push-container --build-arg KEY=value

Cherry-pick Operations

  • /cherry-pick <branch> - Schedule cherry-pick to target branch when PR is merged
    • Multiple branches: /cherry-pick branch1 branch2 branch3
  • /cherry-pick-retry <branch> - Retry a failed cherry-pick (merged PRs only)

Branch Management

  • /rebase - Rebase this PR branch onto its base branch

Label Management

  • /<label-name> - Add a label to the PR
  • /<label-name> cancel - Remove a label from the PR

✅ Merge Requirements

This PR will be automatically approved when the following conditions are met:

  1. Approval: /approve from at least one approver
  2. Status Checks: All required status checks must pass
  3. No Blockers: No wip, hold, has-conflicts labels and PR must be mergeable (no conflicts)
  4. Verified: PR must be marked as verified

📊 Review Process

Approvers and Reviewers

Approvers:

  • krcmarik
  • myakove
  • solenoci

Reviewers:

  • krcmarik
  • myakove
  • solenoci
Available Labels
  • hold
  • verified
  • wip
  • lgtm
  • approve
  • automerge
AI Features
  • Conventional Title: Mode: fix (claude/claude-opus-4-6[1m])
  • Cherry-Pick Conflict Resolution: Enabled (claude/claude-opus-4-6[1m])
  • Test Oracle: Triggers: approved (cursor/gpt-5.4-xhigh-fast); /test-oracle can be used anytime
Security Checks
  • Suspicious Path Detection: Monitors paths: .claude/, .vscode/, .cursor/, .devcontainer/, .pi/, .github/workflows/, .github/actions/
  • Committer Identity Check: Verifies last committer matches PR author
  • Mandatory: Security checks block merge (use /security-override to bypass — maintainers only)

💡 Tips

  • WIP Status: Use /wip when your PR is not ready for review
  • Verification: The verified label is removed on new commits unless the push is detected as a clean rebase
  • Cherry-picking: Cherry-pick labels are processed when the PR is merged
  • Container Builds: Container images are automatically tagged with the PR number
  • Permission Levels: Some commands require approver permissions
  • Auto-verified Users: Certain users have automatic verification and merge privileges

For more information, please refer to the project documentation or contact the maintainers.

@redhat-qe-bot
redhat-qe-bot requested a review from myakove June 14, 2026 08:31
@redhat-qe-bot
redhat-qe-bot requested a review from krcmarik June 14, 2026 08:32
@redhat-qe-bot
redhat-qe-bot requested a review from solenoci June 14, 2026 08:32
@MiriSafra MiriSafra changed the title refactor: PVC-based shared disk device detection feat: PVC-based shared disk device detection Jun 14, 2026

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 2

🤖 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 `@utilities/shared_disk.py`:
- Around line 105-137: The docstring for the _get_pvc_names_from_vm function
claims "cloud-init excluded" in the Returns section, but the code doesn't
explicitly filter out cloud-init volumes; it only returns volumes that have a
persistentVolumeClaim attribute, which naturally excludes cloud-init volumes
that use cloudInitNoCloud or cloudInitConfigDrive sources. Remove the
"cloud-init excluded" text from the docstring's Returns section since this
filtering is implicit behavior based on volume type, not an explicit filter in
the code. Alternatively, if explicit clarity is preferred, add a comment in the
loop explaining that only persistentVolumeClaim volumes are included, which
naturally excludes cloud-init volumes by type.
- Around line 183-198: The function currently uses shared_pvcs.pop() which
arbitrarily selects a PVC when multiple shared PVCs exist, causing
non-deterministic behavior. Add a validation check after the existing empty
check (after the ValueError for no shared PVCs) to explicitly fail if there are
multiple shared PVCs. Check that len(shared_pvcs) equals 1 and raise a
ValueError if it exceeds 1, providing details about all the conflicting shared
PVCs found. Only proceed with the pop() call and subsequent device path
resolution (_index_to_device_path calls) if this validation passes.
🪄 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: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 721a9aef-73aa-45af-9956-266c0546f421

📥 Commits

Reviewing files that changed from the base of the PR and between ceeb80c and 6246d22.

📒 Files selected for processing (2)
  • tests/shared_disk/test_shared_disk_rhel_migration.py
  • utilities/shared_disk.py

Comment thread utilities/shared_disk.py Resolved
Comment thread utilities/shared_disk.py Resolved
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 14, 2026
@MiriSafra

Copy link
Copy Markdown
Member Author

/verified

Comment thread utilities/shared_disk.py Resolved

@myakove myakove left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Code Review

Found 3 issue(s) in this PR:

💡 Suggestions (3)

File Line Issue
utilities/shared_disk.py 131 Potential device path mismatch: _get_pvc_names_from_vm collects only PVC-b
utilities/shared_disk.py 171 Previous review comment still unresolved: consider returning a dict instead of
utilities/shared_disk.py 148 No bounds check — if idx >= 26, chr(ord('a') + idx) produces non-letter char

Review generated by pi

Comment thread utilities/shared_disk.py Resolved
Comment thread utilities/shared_disk.py Resolved
Comment thread utilities/shared_disk.py Resolved
- Assign vmi once to avoid race between check and use
- Use TimeoutSampler sample instead of re-fetching vmi.instance (TOCTOU)
- Preserve exception chain with 'from exc' for CI diagnostics
- Handle missing vol_status.target as transient state (clear and retry)
  instead of raising immediately — KubeVirt populates targets incrementally
- Extract magic numbers into named constants
- Add debug logging after PVC device mapping
- Initialize sample=None before TimeoutSampler loop so the except
  handler never hits NameError if the loop never yields.
- Replace captured vmi reference with lambda that re-fetches
  cnv_vm.vmi each iteration, preventing stale reference if VMI
  is recreated during the polling window.
@MiriSafra
MiriSafra force-pushed the feat/pvc-based-shared-disk-detection branch from dabf89b to 36b6855 Compare June 15, 2026 10:00
@redhat-qe-bot

Copy link
Copy Markdown

Clean rebase detected — no code changes compared to previous head (dabf89b).
The following labels were preserved: lgtm-coderabbitai[bot], commented-MiriSafra.

The early `if not cnv_vm.vmi` check contradicts the polling pattern:
if VMI is transiently absent (restart, migration settling), it crashes
immediately instead of letting the TimeoutSampler wait patiently.

The lambda already handles VMI absence (`cnv_vm.vmi.instance if
cnv_vm.vmi else None`), and `if not sample: continue` skips None
returns. Removing the guard makes the function resilient to transient
VMI absence while still producing clear diagnostics on timeout
(phase: no-sample).
@MiriSafra

Copy link
Copy Markdown
Member Author

/verified

@myakove

myakove commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

/lgtm
/approve

@redhat-qe-bot

Copy link
Copy Markdown

New container for ghcr.io/redhatqe/mtv-api-tests:latest published

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants