Skip to content

feat: detect shared disk device path dynamically - #538

Merged
krcmarik merged 4 commits into
RedHatQE:mainfrom
MiriSafra:feat/dynamic-shared-disk-device
Jun 5, 2026
Merged

krcmarik merged 4 commits into
RedHatQE:mainfrom
MiriSafra:feat/dynamic-shared-disk-device

Conversation

@MiriSafra

@MiriSafra MiriSafra commented Jun 3, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Replace hardcoded shared_disk_device: "/dev/vdc" with dynamic detection based on SCSI controller layout
  • Add _get_shared_disk_device() helper that identifies the shared disk by finding the first disk on a different SCSI controller (Multi-writer requires separate controller with bus sharing)
  • Remove shared_disk_device from test config — no longer needed

Changed Files

File Change
utilities/shared_disk.py Add _get_shared_disk_device(), use in verify_shared_disk_data()
tests/tests_config/config.py Remove hardcoded shared_disk_device key

@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 3, 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b22ac89f-96c1-4ad0-b3ec-2305495d452f

📥 Commits

Reviewing files that changed from the base of the PR and between dda1fd6 and be35fef.

📒 Files selected for processing (2)
  • tests/tests_config/config.py
  • utilities/shared_disk.py
💤 Files with no reviewable changes (1)
  • tests/tests_config/config.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • utilities/shared_disk.py

Summary by CodeRabbit

  • Tests

    • Removed hardcoded shared disk device parameter from test configuration.
  • Refactor

    • Shared disk device path is now dynamically determined from VM disk layout instead of using a static value.

Walkthrough

Replaces a hardcoded shared_disk_device with runtime detection from the source VM disk layout via a new helper; verify_shared_disk_data calls the helper to compute the device and the test config entry no longer contains the hardcoded device.

Changes

Shared Disk Device Dynamic Detection

Layer / File(s) Summary
Shared disk device dynamic detection
utilities/shared_disk.py
Introduces _get_shared_disk_device helper to compute /dev/vdX device paths by sorting source VM disks by controller/unit order, selecting the first disk on a non-boot controller, logging detection, and raising ValueError if no suitable disk is found. Docstring for verify_shared_disk_data's prepared_plan parameter is updated to reference virtual_machines and source_vms_data.
Verification integration and test cleanup
utilities/shared_disk.py, tests/tests_config/config.py
verify_shared_disk_data replaces direct prepared_plan["shared_disk_device"] access with a call to _get_shared_disk_device, computing the device path at runtime. Test configuration for test_shared_disk_rhel_migration removes the hardcoded shared_disk_device entry while preserving migration and power-state settings.

Sequence Diagram(s)

sequenceDiagram
  participant verify_shared_disk_data
  participant _get_shared_disk_device
  participant prepared_plan_source_vms_data
  verify_shared_disk_data->>_get_shared_disk_device: request device for vm_name
  _get_shared_disk_device->>prepared_plan_source_vms_data: read disks for vm_name
  _get_shared_disk_device-->>verify_shared_disk_data: return detected /dev/vdX or raise ValueError
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

size/L, commented-coderabbitai[bot], commented-MiriSafra

Suggested reviewers

  • krcmarik
  • myakove
  • solenoci
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: detecting the shared disk device path dynamically instead of using hardcoded values.
Description check ✅ Passed The description is well-related to the changeset, explaining the removal of hardcoded shared_disk_device, the new _get_shared_disk_device() helper function, and the logic for detecting shared disk by SCSI controller layout.
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.

@rh-bot-1

rh-bot-1 commented Jun 3, 2026

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

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

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:

  • 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

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

@MiriSafra

Copy link
Copy Markdown
Member Author

/verified

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

🤖 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 117-119: The code assumes disks is non-empty and does
sorted_disks[0] which will raise an opaque IndexError for malformed VM data; add
a guard right after retrieving disks (the variable disks from
prepared_plan["source_vms_data"][vm_name]["disks"]) to check if not disks and
raise a clear ValueError that includes the vm_name and a short explanation
(e.g., "no disks found for VM <vm_name> in source_vms_data"). This makes the
failure explicit before computing sorted_disks and setting boot_controller.
🪄 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: 6559942a-57fb-4abf-9bd0-ce782189620f

📥 Commits

Reviewing files that changed from the base of the PR and between 5a07c54 and bef714a.

📒 Files selected for processing (2)
  • tests/tests_config/config.py
  • utilities/shared_disk.py
💤 Files with no reviewable changes (1)
  • tests/tests_config/config.py

Comment thread utilities/shared_disk.py Resolved
@redhat-qe-bot2

Copy link
Copy Markdown

Clean rebase detected — no code changes compared to previous head (bef714a).
The following labels were preserved: verified, changes-requested-coderabbitai[bot].

coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 3, 2026
@MiriSafra

Copy link
Copy Markdown
Member Author

/verified

@MiriSafra
MiriSafra marked this pull request as draft June 3, 2026 15:40
@MiriSafra MiriSafra changed the title feat: detect shared disk device path dynamically WIP:feat: detect shared disk device path dynamically Jun 3, 2026
@MiriSafra
MiriSafra marked this pull request as ready for review June 3, 2026 16:00
@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 →

@MiriSafra

Copy link
Copy Markdown
Member Author

/verified

@krcmarik krcmarik 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 1 issue(s) in this PR:

💡 Suggestions (1)

File Line Issue
utilities/shared_disk.py 120 The detection is probably good enough for the current test setup but relies on t

Review generated by Claude Code

Comment thread utilities/shared_disk.py Resolved

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

Caution

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

⚠️ Outside diff range comments (1)
utilities/shared_disk.py (1)

164-213: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

HIGH: Detect the shared device separately for each VM.

For the feat: detect shared disk device path dynamically change, Line 164 still keeps the old plan-wide assumption alive: _get_shared_disk_device() is VM-scoped, but verify_shared_disk_data() derives /dev/vdX from vm1_name once and reuses that path for VM2 as well. If the two source VMs do not have identical disk layouts, VM2 will mount the wrong block device or fail before the data check.

Proposed fix
-    shared_disk_device = _get_shared_disk_device(prepared_plan, vm1_name)
+    vm1_shared_disk_device = _get_shared_disk_device(prepared_plan, vm1_name)
+    vm2_shared_disk_device = _get_shared_disk_device(prepared_plan, vm2_name)
@@
-    partition = f"{shared_disk_device}1"
+    vm1_partition = f"{vm1_shared_disk_device}1"
+    vm2_partition = f"{vm2_shared_disk_device}1"
     test_file_vm1 = f"{mount_point}/test-vm1.txt"
     test_file_vm2 = f"{mount_point}/test-vm2.txt"
@@
-    LOGGER.info(f"VM1 ({vm1_name}): Mounting shared disk {partition}")
+    LOGGER.info(f"VM1 ({vm1_name}): Mounting shared disk {vm1_partition}")
     with ssh_vm1:
-        _mount_shared_partition(ssh_vm1, partition, mount_point, "VM1")
+        _mount_shared_partition(ssh_vm1, vm1_partition, mount_point, "VM1")
@@
-        LOGGER.info(f"VM2 ({vm2_name}): Mounting shared disk {partition}")
+        LOGGER.info(f"VM2 ({vm2_name}): Mounting shared disk {vm2_partition}")
         with ssh_vm2:
-            _mount_shared_partition(ssh_vm2, partition, mount_point, "VM2")
+            _mount_shared_partition(ssh_vm2, vm2_partition, mount_point, "VM2")
@@
-        _run_cmd_on_vm(ssh_vm1, ["sudo", "blockdev", "--flushbufs", shared_disk_device], "VM1 flush buffers")
-        _run_cmd_on_vm(ssh_vm1, ["sudo", "mount", partition, mount_point], "VM1 remount")
+        _run_cmd_on_vm(
+            ssh_vm1,
+            ["sudo", "blockdev", "--flushbufs", vm1_shared_disk_device],
+            "VM1 flush buffers",
+        )
+        _run_cmd_on_vm(ssh_vm1, ["sudo", "mount", vm1_partition, mount_point], "VM1 remount")
🤖 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 `@utilities/shared_disk.py` around lines 164 - 213, The code assumes a single
shared_disk_device computed once for vm1 and reused for vm2; instead call
_get_shared_disk_device separately for each VM (e.g., compute
shared_disk_device_vm1 = _get_shared_disk_device(prepared_plan, vm1_name) and
shared_disk_device_vm2 = _get_shared_disk_device(prepared_plan, vm2_name)),
derive partition_vm1 and partition_vm2 (f"{...}1"), and use partition_vm1 for
all vm1 mounts/flushes and partition_vm2 for all vm2 mounts/reads/writes; update
every place referencing shared_disk_device/partition (mount/unmount,
_run_cmd_on_vm blockdev/flush, and mount commands) to use the per-VM variables
so each VM uses its own detected device.
🤖 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.

Outside diff comments:
In `@utilities/shared_disk.py`:
- Around line 164-213: The code assumes a single shared_disk_device computed
once for vm1 and reused for vm2; instead call _get_shared_disk_device separately
for each VM (e.g., compute shared_disk_device_vm1 =
_get_shared_disk_device(prepared_plan, vm1_name) and shared_disk_device_vm2 =
_get_shared_disk_device(prepared_plan, vm2_name)), derive partition_vm1 and
partition_vm2 (f"{...}1"), and use partition_vm1 for all vm1 mounts/flushes and
partition_vm2 for all vm2 mounts/reads/writes; update every place referencing
shared_disk_device/partition (mount/unmount, _run_cmd_on_vm blockdev/flush, and
mount commands) to use the per-VM variables so each VM uses its own detected
device.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 499dbd0d-523d-46ad-a08a-ed8c0284e622

📥 Commits

Reviewing files that changed from the base of the PR and between bef714a and dda1fd6.

📒 Files selected for processing (2)
  • tests/tests_config/config.py
  • utilities/shared_disk.py
💤 Files with no reviewable changes (1)
  • tests/tests_config/config.py

@MiriSafra

Copy link
Copy Markdown
Member Author

/verified

MiriSafra added 4 commits June 4, 2026 13:11
Replace hardcoded shared_disk_device "/dev/vdc" with runtime detection
based on SCSI controller layout. The shared disk is identified by being
on a different SCSI controller than the boot disk (Multi-writer requires
separate controller with bus sharing enabled).
@MiriSafra
MiriSafra force-pushed the feat/dynamic-shared-disk-device branch from dda1fd6 to be35fef Compare June 4, 2026 10:11
@redhat-qe-bot

Copy link
Copy Markdown

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

@krcmarik

krcmarik commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

/lgtm
/approve

@krcmarik
krcmarik merged commit 19cfb6e into RedHatQE:main Jun 5, 2026
7 checks passed
@redhat-qe-bot2

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