From 26a1ed3f2dd64e9d8baa80857c236770915f7350 Mon Sep 17 00:00:00 2001 From: Luan Nunes Utimura Date: Mon, 29 May 2023 20:15:58 -0300 Subject: [PATCH] Support ceph dev version during pool creation It has been observed that, right after applying stx-openstack, an alarm related to Ceph is being triggered by the platform due to pools not being associated with the applications using them. According the official documentation, the pool/application association is mandatory for Ceph releases equal to or greater than the Luminous release (12.2.13). In theory, this is already handled in openstack-helm's helm charts, such as in Cinder's `storage-init` job. One can even see that it only performs the association for Ceph major versions >= 12, which matches the official documentation's requirements. However, the code in these `storage-init` jobs assumes that `ceph mgr versions` will always report a numeric version, e.g.: - `ceph version 14.2.15-2-g7407245e7b \ (7407245e7b329ac9d475f61e2cbf9f8c616505d6) nautilus (stable)` The problem is that this is not always the case, especially after the platform was migrated to Debian, which Ceph started to report: - `ceph version Development (no_version) nautilus (stable)` As a result, version checks like the one done in Cinder's `storage-init` job are failing and consequently pools are being created without the necessary associations. Therefore, this change updates the storage init scripts for Cinder and Glance to account for the scenario where a development version of Ceph is used. Signed-off-by: Luan Nunes Utimura Change-Id: I464f8a1f8dcb0a5c6523647690723517dd1281b4 --- .../templates/bin/_backup-storage-init.sh.tpl | 26 +++++++++++++++++- cinder/templates/bin/_storage-init.sh.tpl | 26 +++++++++++++++++- glance/templates/bin/_storage-init.sh.tpl | 27 +++++++++++++++++-- 3 files changed, 75 insertions(+), 4 deletions(-) diff --git a/cinder/templates/bin/_backup-storage-init.sh.tpl b/cinder/templates/bin/_backup-storage-init.sh.tpl index a50ecb74..1601172a 100644 --- a/cinder/templates/bin/_backup-storage-init.sh.tpl +++ b/cinder/templates/bin/_backup-storage-init.sh.tpl @@ -32,8 +32,32 @@ elif [[ $STORAGE_BACKEND =~ 'cinder.backup.drivers.ceph' ]]; then ceph -s function ensure_pool () { ceph osd pool stats $1 || ceph osd pool create $1 $2 - if [[ $(ceph mgr versions | awk '/version/{print $3}' | cut -d. -f1) -ge 12 ]]; then + + # As of the Luminous release, it is mandatory to enable applications on pools. + # To find out if the release is greater than (or equal to) Luminous, just check + # if Ceph's major version is >= 12. + CEPH_MAJOR_VERSION=$(ceph mgr versions | awk '/version/{print $3}' | cut -d. -f1) + if [[ $CEPH_MAJOR_VERSION -ge 12 ]]; then + ceph osd pool application enable $1 $3 + else + # If Ceph's major version shows as "Development", there is chance that it is + # still greater than (or equal to) Luminous. In this case, just check the + # release name against the name of releases prior to Luminous. + CEPH_RELEASE_NAME=$(ceph mgr versions | awk '/version/{print $5}') + CEPH_RELEASES_PRIOR_TO_LUMINOUS=( + kraken + jewel + infernalis + hammer + giant + firefly + emperor + dumpling + ) + if [[ $CEPH_MAJOR_VERSION -eq "Development" && \ + !(" ${CEPH_RELEASES_PRIOR_TO_LUMINOUS[*]} " =~ " $CEPH_RELEASE_NAME ") ]]; then ceph osd pool application enable $1 $3 + fi fi size_protection=$(ceph osd pool get $1 nosizechange | cut -f2 -d: | tr -d '[:space:]') ceph osd pool set $1 nosizechange 0 diff --git a/cinder/templates/bin/_storage-init.sh.tpl b/cinder/templates/bin/_storage-init.sh.tpl index 4f945e2c..4d1c28e4 100644 --- a/cinder/templates/bin/_storage-init.sh.tpl +++ b/cinder/templates/bin/_storage-init.sh.tpl @@ -29,8 +29,32 @@ if [ "x$STORAGE_BACKEND" == "xcinder.volume.drivers.rbd.RBDDriver" ]; then ceph -s function ensure_pool () { ceph osd pool stats $1 || ceph osd pool create $1 $2 - if [[ $(ceph mgr versions | awk '/version/{print $3}' | cut -d. -f1) -ge 12 ]]; then + + # As of the Luminous release, it is mandatory to enable applications on pools. + # To find out if the release is greater than (or equal to) Luminous, just check + # if Ceph's major version is >= 12. + CEPH_MAJOR_VERSION=$(ceph mgr versions | awk '/version/{print $3}' | cut -d. -f1) + if [[ $CEPH_MAJOR_VERSION -ge 12 ]]; then + ceph osd pool application enable $1 $3 + else + # If Ceph's major version shows as "Development", there is chance that it is + # still greater than (or equal to) Luminous. In this case, just check the + # release name against the name of releases prior to Luminous. + CEPH_RELEASE_NAME=$(ceph mgr versions | awk '/version/{print $5}') + CEPH_RELEASES_PRIOR_TO_LUMINOUS=( + kraken + jewel + infernalis + hammer + giant + firefly + emperor + dumpling + ) + if [[ $CEPH_MAJOR_VERSION -eq "Development" && \ + !(" ${CEPH_RELEASES_PRIOR_TO_LUMINOUS[*]} " =~ " $CEPH_RELEASE_NAME ") ]]; then ceph osd pool application enable $1 $3 + fi fi size_protection=$(ceph osd pool get $1 nosizechange | cut -f2 -d: | tr -d '[:space:]') ceph osd pool set $1 nosizechange 0 diff --git a/glance/templates/bin/_storage-init.sh.tpl b/glance/templates/bin/_storage-init.sh.tpl index 0d291fd2..97880d3c 100644 --- a/glance/templates/bin/_storage-init.sh.tpl +++ b/glance/templates/bin/_storage-init.sh.tpl @@ -45,9 +45,32 @@ elif [ "x$STORAGE_BACKEND" == "xrbd" ]; then ceph -s function ensure_pool () { ceph osd pool stats "$1" || ceph osd pool create "$1" "$2" - local test_version - if [[ $(ceph mgr versions | awk '/version/{print $3}' | cut -d. -f1) -ge 12 ]]; then + + # As of the Luminous release, it is mandatory to enable applications on pools. + # To find out if the release is greater than (or equal to) Luminous, just check + # if Ceph's major version is >= 12. + CEPH_MAJOR_VERSION=$(ceph mgr versions | awk '/version/{print $3}' | cut -d. -f1) + if [[ $CEPH_MAJOR_VERSION -ge 12 ]]; then + ceph osd pool application enable $1 $3 + else + # If Ceph's major version shows as "Development", there is chance that it is + # still greater than (or equal to) Luminous. In this case, just check the + # release name against the name of releases prior to Luminous. + CEPH_RELEASE_NAME=$(ceph mgr versions | awk '/version/{print $5}') + CEPH_RELEASES_PRIOR_TO_LUMINOUS=( + kraken + jewel + infernalis + hammer + giant + firefly + emperor + dumpling + ) + if [[ $CEPH_MAJOR_VERSION -eq "Development" && \ + !(" ${CEPH_RELEASES_PRIOR_TO_LUMINOUS[*]} " =~ " $CEPH_RELEASE_NAME ") ]]; then ceph osd pool application enable $1 $3 + fi fi ceph osd pool set "$1" size "${RBD_POOL_REPLICATION}" --yes-i-really-mean-it ceph osd pool set "$1" crush_rule "${RBD_POOL_CRUSH_RULE}" -- 2.25.1