From aaa997114b8a4c5e80f55933609c26dbe33bcc16 Mon Sep 17 00:00:00 2001 From: Jaesang Lee Date: Tue, 9 Jan 2018 11:08:20 +0900 Subject: [PATCH] Ceph: fix ensure pool function for older than luminous The storage_init script in some charts has a code that doesn't work with older than ceph luminous. This PS allows execution in both ceph luminous and older versions like kraken jewel. Change-Id: I5d21fb027328e7d3490625894bd14905988ba320 Closes-bug: 1742021 --- ceph/values.yaml | 5 ++++- cinder/templates/bin/_backup-storage-init.sh.tpl | 5 ++++- cinder/templates/bin/_storage-init.sh.tpl | 5 ++++- glance/templates/bin/_storage-init.sh.tpl | 5 ++++- gnocchi/templates/bin/_storage-init.sh.tpl | 5 ++++- 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/ceph/values.yaml b/ceph/values.yaml index 0d7cdf55ca..ad7332bdba 100644 --- a/ceph/values.yaml +++ b/ceph/values.yaml @@ -312,7 +312,10 @@ bootstrap: ceph -s function ensure_pool () { ceph osd pool stats $1 || ceph osd pool create $1 $2 - ceph osd pool application enable $1 $3 + local test_luminous=$(ceph -v | egrep -q "12.2|luminous"; echo $?) + if [[ ${test_luminous} -ne 0 ]]; then + ceph osd pool application enable $1 $3 + fi } #ensure_pool volumes 8 cinder diff --git a/cinder/templates/bin/_backup-storage-init.sh.tpl b/cinder/templates/bin/_backup-storage-init.sh.tpl index c5db2ed9cb..3121f560c6 100644 --- a/cinder/templates/bin/_backup-storage-init.sh.tpl +++ b/cinder/templates/bin/_backup-storage-init.sh.tpl @@ -34,7 +34,10 @@ elif [ "x$STORAGE_BACKEND" == "xcinder.backup.drivers.ceph" ]; then ceph -s function ensure_pool () { ceph osd pool stats $1 || ceph osd pool create $1 $2 - ceph osd pool application enable $1 $3 + local test_luminous=$(ceph -v | egrep -q "12.2|luminous"; echo $?) + if [[ ${test_luminous} -ne 0 ]]; then + ceph osd pool application enable $1 $3 + fi } ensure_pool ${RBD_POOL_NAME} ${RBD_POOL_CHUNK_SIZE} "cinder-backup" diff --git a/cinder/templates/bin/_storage-init.sh.tpl b/cinder/templates/bin/_storage-init.sh.tpl index 2d32249f6c..14b7c67feb 100644 --- a/cinder/templates/bin/_storage-init.sh.tpl +++ b/cinder/templates/bin/_storage-init.sh.tpl @@ -31,7 +31,10 @@ 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 - ceph osd pool application enable $1 $3 + local test_luminous=$(ceph -v | egrep -q "12.2|luminous"; echo $?) + if [[ ${test_luminous} -ne 0 ]]; then + ceph osd pool application enable $1 $3 + fi } ensure_pool ${RBD_POOL_NAME} ${RBD_POOL_CHUNK_SIZE} "cinder-volume" diff --git a/glance/templates/bin/_storage-init.sh.tpl b/glance/templates/bin/_storage-init.sh.tpl index e02aebeaf5..80fe765573 100644 --- a/glance/templates/bin/_storage-init.sh.tpl +++ b/glance/templates/bin/_storage-init.sh.tpl @@ -33,7 +33,10 @@ elif [ "x$STORAGE_BACKEND" == "xrbd" ]; then ceph -s function ensure_pool () { ceph osd pool stats $1 || ceph osd pool create $1 $2 - ceph osd pool application enable $1 $3 + local test_luminous=$(ceph -v | egrep -q "12.2|luminous"; echo $?) + if [[ ${test_luminous} -ne 0 ]]; then + ceph osd pool application enable $1 $3 + fi } ensure_pool ${RBD_POOL_NAME} ${RBD_POOL_CHUNK_SIZE} "glance-image" diff --git a/gnocchi/templates/bin/_storage-init.sh.tpl b/gnocchi/templates/bin/_storage-init.sh.tpl index ec40b867c9..6c08db0db9 100644 --- a/gnocchi/templates/bin/_storage-init.sh.tpl +++ b/gnocchi/templates/bin/_storage-init.sh.tpl @@ -28,7 +28,10 @@ set -ex ceph -s function ensure_pool () { ceph osd pool stats $1 || ceph osd pool create $1 $2 - ceph osd pool application enable $1 $3 + local test_luminous=$(ceph -v | egrep -q "12.2|luminous"; echo $?) + if [[ ${test_luminous} -ne 0 ]]; then + ceph osd pool application enable $1 $3 + fi } ensure_pool ${RBD_POOL_NAME} ${RBD_POOL_CHUNK_SIZE} "gnocchi-metrics"