diff options
| author | Zuul <zuul@review.opendev.org> | 2019-10-16 10:11:51 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2019-10-16 10:11:51 +0000 |
| commit | 218f24fa90d3aac2b0d7efd20e284f834da092f7 (patch) | |
| tree | f301b07fdb6dd7e690e500355956b76afcfeaea2 /docker | |
| parent | 88d26e52d350683f4407191ccb196a203167e756 (diff) | |
| parent | 1d5f753fb13bcc3659b4abd1bb768de8550a6dc4 (diff) | |
| download | kolla-218f24fa90d3aac2b0d7efd20e284f834da092f7.tar.gz kolla-218f24fa90d3aac2b0d7efd20e284f834da092f7.zip | |
Merge "Add disk dev name check function"
Diffstat (limited to 'docker')
| -rw-r--r-- | docker/ceph/ceph-osd/extend_start.sh | 59 |
1 files changed, 20 insertions, 39 deletions
diff --git a/docker/ceph/ceph-osd/extend_start.sh b/docker/ceph/ceph-osd/extend_start.sh index 5590afabd..f1a7f776f 100644 --- a/docker/ceph/ceph-osd/extend_start.sh +++ b/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}" |
