fix lvms failure when no additional disk - #46
Conversation
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe change documents optional loopback fallback settings and provisions virtual loopback disks when no common node disks are detected, then validates the configured device on each node. ChangesLoopback disk fallback
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant ValuesPrep
participant RemoteNode
participant Losetup
ValuesPrep->>RemoteNode: Discover common disks
RemoteNode-->>ValuesPrep: Return disk lists
ValuesPrep->>RemoteNode: Create virtual disk image
RemoteNode->>Losetup: Attach image with losetup -P
Losetup-->>RemoteNode: Return loop device
RemoteNode-->>ValuesPrep: Return attached device
ValuesPrep->>RemoteNode: Validate configured loop device
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
Comment |
There was a problem hiding this comment.
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 `@ansible/roles/values-prep/tasks/find-node-disks.yml`:
- Around line 46-49: Update the loop-device setup block to verify that $LOOP_DEV
specifically is attached to $DISK_IMG, rather than checking whether the image is
attached to any loop device. Only detach $LOOP_DEV when it is currently
associated with $DISK_IMG; otherwise avoid disrupting unrelated loop devices,
then attach the image to the intended device and preserve the existing
verification flow.
🪄 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: Organization UI
Review profile: CHILL
Plan: Enterprise
Run ID: 44140f53-63aa-4b11-8a9a-1602c8f179cc
📒 Files selected for processing (2)
ansible/group_vars/all.sample.ymlansible/roles/values-prep/tasks/find-node-disks.yml
| if ! sudo losetup -j "$DISK_IMG" 2>/dev/null | grep -q .; then | ||
| sudo losetup -d "$LOOP_DEV" 2>/dev/null || true | ||
| sudo losetup -P "$LOOP_DEV" "$DISK_IMG" | ||
| fi |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Idempotency check doesn't verify $LOOP_DEV specifically backs $DISK_IMG.
losetup -j "$DISK_IMG" matches any loop device backing the image, not $LOOP_DEV specifically. If the image ends up attached to a different loop number (e.g., leftover from a prior run/other tooling), this block skips reattachment and the trailing losetup -j | awk prints that other device — later failing the Verify virtual loop device assert with a confusing message rather than self-healing. Conversely, losetup -d "$LOOP_DEV" unconditionally detaches whatever is currently on $LOOP_DEV, even if unrelated to $DISK_IMG, which is destructive if that loop number is already in use by something else on the node.
🔧 Proposed fix: check the specific loop device
- if ! sudo losetup -j "$DISK_IMG" 2>/dev/null | grep -q .; then
- sudo losetup -d "$LOOP_DEV" 2>/dev/null || true
- sudo losetup -P "$LOOP_DEV" "$DISK_IMG"
- fi
+ if ! sudo losetup -j "$DISK_IMG" 2>/dev/null | grep -q "^${LOOP_DEV}:"; then
+ sudo losetup -d "$LOOP_DEV" 2>/dev/null || true
+ sudo losetup -P "$LOOP_DEV" "$DISK_IMG"
+ fi🤖 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 `@ansible/roles/values-prep/tasks/find-node-disks.yml` around lines 46 - 49,
Update the loop-device setup block to verify that $LOOP_DEV specifically is
attached to $DISK_IMG, rather than checking whether the image is attached to any
loop device. Only detach $LOOP_DEV when it is currently associated with
$DISK_IMG; otherwise avoid disrupting unrelated loop devices, then attach the
image to the intended device and preserve the existing verification flow.
No description provided.