Browse Source

Add disk dev name check function

This patch will add new function in extend_start.sh for OSD
creation. Not only support loop device but also others that
disk dev layout is end with numbers.

Change-Id: Iee5f8b8581d70166de6eba1bdc9e42766fe8cb48
Closes-Bug: #1847014
(cherry picked from commit 1d5f753fb1)
changes/26/688926/1
Eddie Yen 2 years ago
parent
commit
6bc6469bc6
  1. 59
      docker/ceph/ceph-osd/extend_start.sh

59
docker/ceph/ceph-osd/extend_start.sh

@ -33,6 +33,16 @@ function wait_partition_appear {
exit 1
}
# Few storage device like loop or NVMe, wiil add "p" between disk & partition
# name if disk layout is end with number. This function will fix to correct format.
function part_name_checker {
if [[ $1 =~ .*[0-9] ]]; then
echo ${1}p${2}
else
echo ${1}${2}
fi
}
# 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
@ -48,47 +58,26 @@ if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then
if [[ "${USE_EXTERNAL_JOURNAL}" == "False" ]]; then
# Formatting disk for ceph
if [[ "${OSD_STORETYPE}" == "bluestore" ]]; then
if [[ "${OSD_BS_DEV}" =~ "/dev/loop" ]]; then
sgdisk --zap-all -- "${OSD_BS_DEV}""p${OSD_BS_PARTNUM}"
else
sgdisk --zap-all -- "${OSD_BS_DEV}""${OSD_BS_PARTNUM}"
fi
sgdisk --zap-all -- "$(part_name_checker $OSD_BS_DEV $OSD_BS_PARTNUM)"
if [ -n "${OSD_BS_BLK_DEV}" ] && [ "${OSD_BS_DEV}" != "${OSD_BS_BLK_DEV}" ] && [ -n "${OSD_BS_BLK_PARTNUM}" ]; then
if [[ "${OSD_BS_BLK_DEV}" =~ "/dev/loop" ]]; then
sgdisk --zap-all -- "${OSD_BS_BLK_DEV}""p${OSD_BS_BLK_PARTNUM}"
else
sgdisk --zap-all -- "${OSD_BS_BLK_DEV}""${OSD_BS_BLK_PARTNUM}"
fi
sgdisk --zap-all -- "$(part_name_checker ${OSD_BS_BLK_DEV} ${OSD_BS_BLK_PARTNUM})"
else
sgdisk --zap-all -- "${OSD_BS_DEV}"
sgdisk --new=1:0:+100M --mbrtogpt -- "${OSD_BS_DEV}"
sgdisk --largest-new=2 --mbrtogpt -- "${OSD_BS_DEV}"
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
wait_partition_appear "$(part_name_checker $OSD_BS_DEV 2)"
sgdisk --zap-all -- "$(part_name_checker $OSD_BS_DEV 2)"
fi
if [ -n "${OSD_BS_WAL_DEV}" ] && [ "${OSD_BS_BLK_DEV}" != "${OSD_BS_WAL_DEV}" ] && [ -n "${OSD_BS_WAL_PARTNUM}" ]; then
if [[ "${OSD_BS_WAL_DEV}" =~ "/dev/loop" ]]; then
sgdisk --zap-all -- "${OSD_BS_WAL_DEV}""p${OSD_BS_WAL_PARTNUM}"
else
sgdisk --zap-all -- "${OSD_BS_WAL_DEV}""${OSD_BS_WAL_PARTNUM}"
fi
sgdisk --zap-all -- "$(part_name_checker $OSD_BS_WAL_DEV $OSD_BS_WAL_PARTNUM)"
fi
if [ -n "${OSD_BS_DB_DEV}" ] && [ "${OSD_BS_BLK_DEV}" != "${OSD_BS_DB_DEV}" ] && [ -n "${OSD_BS_DB_PARTNUM}" ]; then
if [[ "${OSD_BS_DB_DEV}" =~ "/dev/loop" ]]; then
sgdisk --zap-all -- "${OSD_BS_DB_DEV}""p${OSD_BS_DB_PARTNUM}"
else
sgdisk --zap-all -- "${OSD_BS_DB_DEV}""${OSD_BS_DB_PARTNUM}"
fi
sgdisk --zap-all -- "$(part_name_checker $OSD_BS_DB_DEV $OSD_BS_DB_PARTNUM)"
fi
else
sgdisk --zap-all -- "${OSD_DEV}"
@ -106,13 +95,8 @@ if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then
OSD_DIR="/var/lib/ceph/osd/ceph-${OSD_ID}"
mkdir -p "${OSD_DIR}"
if [[ "${OSD_BS_DEV}" =~ "/dev/loop" ]]; then
mkfs.xfs -f "${OSD_BS_DEV}""p${OSD_BS_PARTNUM}"
mount "${OSD_BS_DEV}""p${OSD_BS_PARTNUM}" "${OSD_DIR}"
else
mkfs.xfs -f "${OSD_BS_DEV}""${OSD_BS_PARTNUM}"
mount "${OSD_BS_DEV}""${OSD_BS_PARTNUM}" "${OSD_DIR}"
fi
mkfs.xfs -f "$(part_name_checker $OSD_BS_DEV $OSD_BS_PARTNUM)"
mount "$(part_name_checker $OSD_BS_DEV $OSD_BS_PARTNUM)" "${OSD_DIR}"
# This will through an error about no key existing. That is normal. It then
# creates the key in the next step.
@ -158,11 +142,8 @@ if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then
ceph auth add "osd.${OSD_ID}" osd 'allow *' mon 'allow profile osd' -i "${OSD_DIR}/keyring"
if [[ "${OSD_BS_DEV}" =~ "/dev/loop" ]]; then
umount "${OSD_BS_DEV}""p${OSD_BS_PARTNUM}"
else
umount "${OSD_BS_DEV}""${OSD_BS_PARTNUM}"
fi
umount "$(part_name_checker $OSD_BS_DEV $OSD_BS_PARTNUM)"
else
OSD_ID=$(ceph osd create)
OSD_DIR="/var/lib/ceph/osd/ceph-${OSD_ID}"

Loading…
Cancel
Save