Fix Ceph device parsing to use devices line

The "block device" line in ceph-volume output shows LVM paths like
ceph-xxx/osd-block-xxx, not physical device names. Changed to parse
the "devices" line which contains the actual physical device path
like /dev/sda.

Also reset current_osd after match to avoid duplicate matches.

Fixes: #17

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-05 20:10:46 -05:00
parent e6cc9a3853
commit 7579f371d7

View File

@@ -670,12 +670,14 @@ build_ceph_cache() {
# Match OSD header: "====== osd.5 ======="
if [[ "$line" =~ ======[[:space:]]+osd\.([0-9]+)[[:space:]]+======= ]]; then
current_osd="osd.${BASH_REMATCH[1]}"
# Match block device line: " block device /dev/sda"
elif [[ -n "$current_osd" && "$line" =~ block[[:space:]]device[[:space:]]+/dev/([^[:space:]]+) ]]; then
# Match "devices" line which has the actual physical device: " devices /dev/sda"
# This is more reliable than "block device" which may show LVM paths
elif [[ -n "$current_osd" && "$line" =~ devices[[:space:]]+/dev/(sd[a-z]+|nvme[0-9]+n[0-9]+) ]]; then
local dev_name="${BASH_REMATCH[1]}"
CEPH_DEVICE_TO_OSD["$dev_name"]="$current_osd"
((osd_count++))
log_info "Found $current_osd on $dev_name"
current_osd="" # Reset to avoid duplicate matches
fi
done < <(ceph-volume lvm list 2>/dev/null)
log_info "Cached $osd_count Ceph OSDs"