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:
@@ -670,12 +670,14 @@ build_ceph_cache() {
|
|||||||
# Match OSD header: "====== osd.5 ======="
|
# Match OSD header: "====== osd.5 ======="
|
||||||
if [[ "$line" =~ ======[[:space:]]+osd\.([0-9]+)[[:space:]]+======= ]]; then
|
if [[ "$line" =~ ======[[:space:]]+osd\.([0-9]+)[[:space:]]+======= ]]; then
|
||||||
current_osd="osd.${BASH_REMATCH[1]}"
|
current_osd="osd.${BASH_REMATCH[1]}"
|
||||||
# Match block device line: " block device /dev/sda"
|
# Match "devices" line which has the actual physical device: " devices /dev/sda"
|
||||||
elif [[ -n "$current_osd" && "$line" =~ block[[:space:]]device[[:space:]]+/dev/([^[:space:]]+) ]]; then
|
# 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]}"
|
local dev_name="${BASH_REMATCH[1]}"
|
||||||
CEPH_DEVICE_TO_OSD["$dev_name"]="$current_osd"
|
CEPH_DEVICE_TO_OSD["$dev_name"]="$current_osd"
|
||||||
((osd_count++))
|
((osd_count++))
|
||||||
log_info "Found $current_osd on $dev_name"
|
log_info "Found $current_osd on $dev_name"
|
||||||
|
current_osd="" # Reset to avoid duplicate matches
|
||||||
fi
|
fi
|
||||||
done < <(ceph-volume lvm list 2>/dev/null)
|
done < <(ceph-volume lvm list 2>/dev/null)
|
||||||
log_info "Cached $osd_count Ceph OSDs"
|
log_info "Cached $osd_count Ceph OSDs"
|
||||||
|
|||||||
Reference in New Issue
Block a user