From b3ebb46ce23365d77b2502366578646406b3b9cb Mon Sep 17 00:00:00 2001 From: "Parsons, Cliff (cp769u)" Date: Wed, 23 Jun 2021 21:31:35 +0000 Subject: [PATCH] Ceph OSD Init Improvements Some minor improvements are made in this patchset: 1) Move osd_disk_prechecks to the very beginning to make sure the required variables are set before running the bulk of the script. 2) Specify variables in a more consistent manner for readability. 3) Remove variables from CLI commands that are not used/set. Change-Id: I6167b277e111ed59ccf4415e7f7d178fe4338cbd --- ceph-osd/Chart.yaml | 2 +- .../_init-ceph-volume-helper-block-logical.sh.tpl | 8 ++++---- .../osd/ceph-volume/_init-with-ceph-volume.sh.tpl | 14 +++++++------- releasenotes/notes/ceph-osd.yaml | 1 + 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/ceph-osd/Chart.yaml b/ceph-osd/Chart.yaml index 5df42c531..0e9cb0985 100644 --- a/ceph-osd/Chart.yaml +++ b/ceph-osd/Chart.yaml @@ -15,6 +15,6 @@ apiVersion: v1 appVersion: v1.0.0 description: OpenStack-Helm Ceph OSD name: ceph-osd -version: 0.1.23 +version: 0.1.24 home: https://github.com/ceph/ceph ... diff --git a/ceph-osd/templates/bin/osd/ceph-volume/_init-ceph-volume-helper-block-logical.sh.tpl b/ceph-osd/templates/bin/osd/ceph-volume/_init-ceph-volume-helper-block-logical.sh.tpl index fd4f1498d..3154a73c6 100644 --- a/ceph-osd/templates/bin/osd/ceph-volume/_init-ceph-volume-helper-block-logical.sh.tpl +++ b/ceph-osd/templates/bin/osd/ceph-volume/_init-ceph-volume-helper-block-logical.sh.tpl @@ -36,7 +36,7 @@ function check_osd_metadata { local tmpmnt=$(mktemp -d) mount ${DM_DEV} ${tmpmnt} - if [ "x$JOURNAL_TYPE" != "xdirectory" ]; then + if [ "x${JOURNAL_TYPE}" != "xdirectory" ]; then if [ -f "${tmpmnt}/whoami" ]; then OSD_JOURNAL_DISK=$(readlink -f "${tmpmnt}/journal") local osd_id=$(cat "${tmpmnt}/whoami") @@ -113,7 +113,7 @@ function determine_what_needs_zapping { fi if [ ${OSD_FORCE_REPAIR} -eq 1 ] && [ ! -z ${DM_DEV} ]; then - if [ -b $DM_DEV ]; then + if [ -b ${DM_DEV} ]; then local ceph_fsid=$(ceph-conf --lookup fsid) if [ ! -z "${ceph_fsid}" ]; then # Check the OSD metadata and zap the disk if necessary @@ -165,7 +165,7 @@ function osd_journal_prepare { else OSD_JOURNAL=${OSD_JOURNAL} fi - elif [ "x$JOURNAL_TYPE" != "xdirectory" ]; then + elif [ "x${JOURNAL_TYPE}" != "xdirectory" ]; then # The block device exists but doesn't appear to be paritioned, we will proceed with parititioning the device. OSD_JOURNAL=$(readlink -f ${OSD_JOURNAL}) until [ -b ${OSD_JOURNAL} ]; do @@ -173,7 +173,7 @@ function osd_journal_prepare { done fi chown ceph. ${OSD_JOURNAL}; - elif [ "x$JOURNAL_TYPE" != "xdirectory" ]; then + elif [ "x${JOURNAL_TYPE}" != "xdirectory" ]; then echo "No journal device specified. OSD and journal will share ${OSD_DEVICE}" echo "For better performance on HDD, consider moving your journal to a separate device" fi diff --git a/ceph-osd/templates/bin/osd/ceph-volume/_init-with-ceph-volume.sh.tpl b/ceph-osd/templates/bin/osd/ceph-volume/_init-with-ceph-volume.sh.tpl index 3a2e6b154..77fa74b94 100644 --- a/ceph-osd/templates/bin/osd/ceph-volume/_init-with-ceph-volume.sh.tpl +++ b/ceph-osd/templates/bin/osd/ceph-volume/_init-with-ceph-volume.sh.tpl @@ -181,16 +181,16 @@ function osd_disk_prechecks { fi if [[ ! -b "${OSD_DEVICE}" ]]; then - echo "ERROR- The device pointed by OSD_DEVICE ($OSD_DEVICE) doesn't exist !" + echo "ERROR- The device pointed by OSD_DEVICE (${OSD_DEVICE}) doesn't exist !" exit 1 fi - if [ ! -e $OSD_BOOTSTRAP_KEYRING ]; then - echo "ERROR- $OSD_BOOTSTRAP_KEYRING must exist. You can extract it from your current monitor by running 'ceph auth get client.bootstrap-osd -o $OSD_BOOTSTRAP_KEYRING'" + if [ ! -e ${OSD_BOOTSTRAP_KEYRING} ]; then + echo "ERROR- ${OSD_BOOTSTRAP_KEYRING} must exist. You can extract it from your current monitor by running 'ceph auth get client.bootstrap-osd -o ${OSD_BOOTSTRAP_KEYRING}'" exit 1 fi - timeout 10 ceph ${CLI_OPTS} --name client.bootstrap-osd --keyring $OSD_BOOTSTRAP_KEYRING health || exit 1 + timeout 10 ceph --name client.bootstrap-osd --keyring ${OSD_BOOTSTRAP_KEYRING} health || exit 1 } function perform_zap { @@ -212,6 +212,9 @@ function perform_zap { if [[ "${STORAGE_TYPE}" != "directory" ]]; then + # Check to make sure we have what we need to continue + osd_disk_prechecks + # Settle LVM changes before inspecting volumes udev_settle @@ -242,9 +245,6 @@ if [[ "${STORAGE_TYPE}" != "directory" ]]; then # Settle LVM changes again after any changes have been made udev_settle - # Check to make sure we have what we need to continue - osd_disk_prechecks - # Initialize some important global variables CEPH_LVM_PREPARE=1 OSD_ID=$(get_osd_id_from_device ${OSD_DEVICE}) diff --git a/releasenotes/notes/ceph-osd.yaml b/releasenotes/notes/ceph-osd.yaml index 276becdd4..d617a4001 100644 --- a/releasenotes/notes/ceph-osd.yaml +++ b/releasenotes/notes/ceph-osd.yaml @@ -24,4 +24,5 @@ ceph-osd: - 0.1.21 Refactor Ceph OSD Init Scripts - First PS - 0.1.22 Refactor Ceph OSD Init Scripts - Second PS - 0.1.23 Use full image ref for docker official images + - 0.1.24 Ceph OSD Init Improvements ...