aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwangwei <wangwei@navercorp.com>2019-07-10 16:29:48 +0900
committerwangwei <wangwei@navercorp.com>2019-07-10 18:10:53 +0900
commit342c9f0cd0dc4b97870dc40fab6c5a7d241b40ed (patch)
treefa2a54e9a63543cad5b4b4cf41e7e0f979bc1e36
parent008aa957f27b26caff3be8b18110e71cdaf70772 (diff)
downloadkolla-342c9f0cd0dc4b97870dc40fab6c5a7d241b40ed.tar.gz
kolla-342c9f0cd0dc4b97870dc40fab6c5a7d241b40ed.zip
Add partition detection to fix osd initialization failure
The changes in the following commit did not completely solve the problem of osd initialization failure: https://review.opendev.org/652612 In order to solve this problem, the partprobe command consistent with ceph-disk is added, and then a loop is added to detect the partition, which is acquired every 1s. When the partition appears, the osd initialization is continued. Change-Id: I0ca255c6358132d9e3acfa6b610b70a78756512c Closes-bug: #1824787
-rw-r--r--docker/ceph/ceph-osd/extend_start.sh30
1 files changed, 29 insertions, 1 deletions
diff --git a/docker/ceph/ceph-osd/extend_start.sh b/docker/ceph/ceph-osd/extend_start.sh
index 31c4a0ffb..5590afabd 100644
--- a/docker/ceph/ceph-osd/extend_start.sh
+++ b/docker/ceph/ceph-osd/extend_start.sh
@@ -7,6 +7,32 @@ if [[ $(stat -c %a /var/log/kolla/ceph) != "755" ]]; then
chmod 755 /var/log/kolla/ceph
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
# of the KOLLA_BOOTSTRAP variable being set, including empty.
if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then
@@ -38,11 +64,13 @@ if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then
sgdisk --zap-all -- "${OSD_BS_DEV}"
sgdisk --new=1:0:+100M --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
+ wait_partition_appear "${OSD_BS_DEV}"p2
sgdisk --zap-all -- "${OSD_BS_DEV}"p2
else
+ wait_partition_appear "${OSD_BS_DEV}"2
sgdisk --zap-all -- "${OSD_BS_DEV}"2
fi
fi