From 539bdf9833a01e372bdcb4ff99bf7f6c50787336 Mon Sep 17 00:00:00 2001 From: beatzaplenty Date: Wed, 29 Jul 2026 13:58:53 +1000 Subject: [PATCH] fix(ha): resolve data disk device via by-id symlink even in dry-run MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The by-id lookup is read-only so it's safe to run in dry-run mode. Previously it was gated behind `if ! $DRY_RUN`, which always triggered the sdb fallback warning in dry-run — making it look like the device path wasn't reliable when the symlink actually exists on both servers. Now the lookup always runs and the script errors out with a clear message if the by-id symlink is genuinely missing, instead of silently falling back to a guessed /dev/sd* name. Co-Authored-By: Claude Sonnet 4.6 --- scripts/ha/resize-data-disk.sh | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/scripts/ha/resize-data-disk.sh b/scripts/ha/resize-data-disk.sh index 4379cd9..13e6dc1 100755 --- a/scripts/ha/resize-data-disk.sh +++ b/scripts/ha/resize-data-disk.sh @@ -204,17 +204,13 @@ rescan_node() { local node_name=$1 run_fn=$2 # Resolve block device name from the stable by-id symlink on the guest. + # Read-only lookup — safe to run even in dry-run so we show the real device. local blk_dev="" - if ! $DRY_RUN; then - blk_dev=$($run_fn "bash -c 'basename \$(readlink -f /dev/disk/by-id/${DATA_DISK_BYID})'" 2>/dev/null || true) - fi + blk_dev=$($run_fn "bash -c 'basename \$(readlink -f /dev/disk/by-id/${DATA_DISK_BYID})'" 2>/dev/null || true) if [[ -z "$blk_dev" ]]; then - # Fall back: scsi1 → index 1 → sdb, scsi2 → sdc, etc. - local slot_idx - slot_idx=$(echo "$DATA_DISK_SLOT" | grep -oE '[0-9]+$' || echo "1") - blk_dev=$(printf "sd%s" "$(echo "abcdefghij" | cut -c$((slot_idx + 1)))") - echo " WARNING: could not resolve /dev/disk/by-id/${DATA_DISK_BYID} on $node_name;" \ - "falling back to /dev/${blk_dev}" >&2 + echo " ERROR: /dev/disk/by-id/${DATA_DISK_BYID} not found on $node_name" >&2 + echo " Check DATA_DISK_BYID or DATA_DISK_SLOT configuration." >&2 + exit 1 fi echo " ${DRY_PREFIX}Rescanning /dev/${blk_dev} on ${node_name}..."