Merge "Add partition detection to fix osd initialization failure" into stable/rocky
This commit is contained in:
commit
65d5c29753
|
@ -7,6 +7,32 @@ if [[ $(stat -c %a /var/log/kolla/ceph) != "755" ]]; then
|
||||||
chmod 755 /var/log/kolla/ceph
|
chmod 755 /var/log/kolla/ceph
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Inform the os about partition table changes
|
||||||
|
function partprobe_device {
|
||||||
|
local device=$1
|
||||||
|
udevadm settle --timeout=600
|
||||||
|
flock -s ${device} partprobe ${device}
|
||||||
|
udevadm settle --timeout=600
|
||||||
|
}
|
||||||
|
|
||||||
|
# In some cases, the disk partition will not appear immediately, so check every
|
||||||
|
# 1s, try up to 10 times. In general, this interval is enough.
|
||||||
|
function wait_partition_appear {
|
||||||
|
local dev_part=$1
|
||||||
|
local part_name=$(echo ${dev_part} | awk -F '/' '{print $NF}')
|
||||||
|
for(( i=1; i<11; i++ )); do
|
||||||
|
flag=$(ls /dev | awk '/'"${part_name}"'/{print $0}' | wc -l)
|
||||||
|
if [[ "${flag}" -eq 0 ]]; then
|
||||||
|
echo "sleep 1 waits for the partition ${dev_part} to appear: ${i}"
|
||||||
|
sleep 1
|
||||||
|
else
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "The device /dev/${dev_part} does not appear within the limited time 10s."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
# Bootstrap and exit if KOLLA_BOOTSTRAP variable is set. This catches all cases
|
# Bootstrap and exit if KOLLA_BOOTSTRAP variable is set. This catches all cases
|
||||||
# of the KOLLA_BOOTSTRAP variable being set, including empty.
|
# of the KOLLA_BOOTSTRAP variable being set, including empty.
|
||||||
if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then
|
if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then
|
||||||
|
@ -38,11 +64,13 @@ if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then
|
||||||
sgdisk --zap-all -- "${OSD_BS_DEV}"
|
sgdisk --zap-all -- "${OSD_BS_DEV}"
|
||||||
sgdisk --new=1:0:+100M --mbrtogpt -- "${OSD_BS_DEV}"
|
sgdisk --new=1:0:+100M --mbrtogpt -- "${OSD_BS_DEV}"
|
||||||
sgdisk --largest-new=2 --mbrtogpt -- "${OSD_BS_DEV}"
|
sgdisk --largest-new=2 --mbrtogpt -- "${OSD_BS_DEV}"
|
||||||
partprobe || true
|
partprobe_device "${OSD_BS_DEV}"
|
||||||
|
|
||||||
if [[ "${OSD_BS_DEV}" =~ "/dev/loop" ]]; then
|
if [[ "${OSD_BS_DEV}" =~ "/dev/loop" ]]; then
|
||||||
|
wait_partition_appear "${OSD_BS_DEV}"p2
|
||||||
sgdisk --zap-all -- "${OSD_BS_DEV}"p2
|
sgdisk --zap-all -- "${OSD_BS_DEV}"p2
|
||||||
else
|
else
|
||||||
|
wait_partition_appear "${OSD_BS_DEV}"2
|
||||||
sgdisk --zap-all -- "${OSD_BS_DEV}"2
|
sgdisk --zap-all -- "${OSD_BS_DEV}"2
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue