Skip to content

fix lvms failure when no additional disk - #46

Merged
masco merged 1 commit into
mainfrom
fix-lvms-no-disk
Jul 12, 2026
Merged

masco merged 1 commit into
mainfrom
fix-lvms-no-disk

Conversation

@masco

@masco masco commented Jul 12, 2026

Copy link
Copy Markdown
Member

No description provided.

@coderabbitai

coderabbitai Bot commented Jul 12, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Added support for environments without additional physical disks by provisioning and using configured loopback disks.
    • Added optional configuration settings for the loopback disk image, device path, and size.
  • Bug Fixes
    • Improved disk discovery and validation across nodes, ensuring the expected virtual disk is available before proceeding.

Walkthrough

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

Changes

Loopback disk fallback

Layer / File(s) Summary
Disk discovery and fallback configuration
ansible/group_vars/all.sample.yml, ansible/roles/values-prep/tasks/find-node-disks.yml
Adds commented loopback settings and reformats the existing lsblk/JQ disk filtering command without changing its selection logic.
Loopback disk provisioning and validation
ansible/roles/values-prep/tasks/find-node-disks.yml
Creates and attaches virtual disk images when no common disks exist, sets common_disks, and verifies the expected loop device on each node.

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
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive No pull request description was provided, so its relationship to the changeset cannot be assessed. Add a brief description of the fix and affected behavior so reviewers can confirm the intent.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the main change: fixing LVMS failures when no extra disk is available.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2ebdd62 and 3de7e88.

📒 Files selected for processing (2)
  • ansible/group_vars/all.sample.yml
  • ansible/roles/values-prep/tasks/find-node-disks.yml

Comment on lines +46 to +49
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ 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.

@masco
masco merged commit 51f05bf into main Jul 12, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant