From f0d520105d011d5794ca9522bf9334f9eb69646b Mon Sep 17 00:00:00 2001 From: Robert Church Date: Sun, 12 May 2019 00:32:06 -0400 Subject: [PATCH] Fix ceph-pools-audit chart for Ceph Mimic Update the chart to get the 'crush_rule' for various pools instead of the Jewel compliant 'crush_ruleset' Further chart clean up is done to be bashate compliant and also provide cleaner logging. Change-Id: I37186fa3e78ebc63f27fd43b373f9e82004199de Closes-Bug: #1828760 Signed-off-by: Robert Church --- .../templates/bin/_ceph-pools-audit.sh.tpl | 57 ++++++++----------- .../templates/job-ceph-pools-audit.yaml | 4 +- .../sysinv/sysinv/helm/ceph_pools_audit.py | 10 ++-- 3 files changed, 31 insertions(+), 40 deletions(-) diff --git a/kubernetes/helm-charts/ceph-pools-audit/templates/bin/_ceph-pools-audit.sh.tpl b/kubernetes/helm-charts/ceph-pools-audit/templates/bin/_ceph-pools-audit.sh.tpl index 81e7f4a113..5d5a56f095 100755 --- a/kubernetes/helm-charts/ceph-pools-audit/templates/bin/_ceph-pools-audit.sh.tpl +++ b/kubernetes/helm-charts/ceph-pools-audit/templates/bin/_ceph-pools-audit.sh.tpl @@ -9,56 +9,47 @@ */}} ceph -s -ret=$? -if [ $ret -ne 0 ]; then - msg="Error: Ceph cluster is not accessible, check Pod logs for details." - echo "$msg" - exit $ret +if [ $? -ne 0 ]; then + echo "Error: Ceph cluster is not accessible, check Pod logs for details." + exit 1 fi touch /etc/ceph/ceph.client.admin.keyring -echo "RBD_POOL_CRUSH_RULESET: $RBD_POOL_CRUSH_RULESET" -if [ -z $RBD_POOL_CRUSH_RULESET ]; then - msg="No Ceph crush ruleset specified" - echo "$msg" +echo "RBD_POOL_CRUSH_RULE_NAME: ${RBD_POOL_CRUSH_RULE_NAME}" +if [ -z "${RBD_POOL_CRUSH_RULE_NAME}" ]; then + echo "Error: No Ceph crush rule name specified" exit 1 fi -ruleset=$(ceph osd crush rule dump $RBD_POOL_CRUSH_RULESET | grep \"ruleset\" | awk '{print $2}' | grep -Eo '[0-9]+') -ret=$? -if [ $ret -ne 0 ]; then - msg="Ceph crush ruleset $RBD_POOL_CRUSH_RULESET not found, exit" - echo "$msg" - exit $ret +ceph osd crush rule ls | grep -q "${RBD_POOL_CRUSH_RULE_NAME}" +if [ $? -ne 0 ]; then + echo "Error: Ceph crush rule ${RBD_POOL_CRUSH_RULE_NAME} not found, exit" + exit 1 fi -echo "ruleset: $ruleset" - -set -ex POOLS=( $(ceph osd pool ls) ) -for pool_name in "${POOLS[@]}" -do - echo "Check for pool name: $pool_name" +for pool in "${POOLS[@]}"; do + echo "Check for pool name: $pool" - pool_crush_ruleset=$(ceph osd pool get $pool_name crush_ruleset | awk '{print $2}') - echo "pool_crush_ruleset: $pool_crush_ruleset" - if [ "$pool_crush_ruleset" != "$ruleset" ]; then + pool_rule=$(ceph osd pool get $pool crush_rule | awk '{print $2}') + echo "Pool crush rule name: ${pool_rule}" + if [ "${pool_rule}" != "${RBD_POOL_CRUSH_RULE_NAME}" ]; then continue fi - pool_size=$(ceph osd pool get $pool_name size | awk '{print $2}') - pool_min_size=$(ceph osd pool get $pool_name min_size | awk '{print $2}') + pool_size=$(ceph osd pool get $pool size | awk '{print $2}') + pool_min_size=$(ceph osd pool get $pool min_size | awk '{print $2}') - echo "===> pool_size: $pool_size pool_min_size: $pool_min_size" - if [ $pool_size != $RBD_POOL_REPLICATION ]; then - echo "set replication for pool $pool_name at $RBD_POOL_REPLICATION" - ceph osd pool set $pool_name size $RBD_POOL_REPLICATION + echo "===> pool_size: ${pool_size} pool_min_size: ${pool_min_size}" + if [ "${pool_size}" != "${RBD_POOL_REPLICATION}" ]; then + echo "Set size for $pool to ${RBD_POOL_REPLICATION}" + ceph osd pool set $pool size "${RBD_POOL_REPLICATION}" fi - if [ $pool_min_size != $RBD_POOL_MIN_REPLICATION ]; then - echo "set min replication for pool $pool_name at $RBD_POOL_MIN_REPLICATION" - ceph osd pool set $pool_name min_size $RBD_POOL_MIN_REPLICATION + if [ "${pool_min_size}" != "${RBD_POOL_MIN_REPLICATION}" ]; then + echo "Set min_size for $pool to ${RBD_POOL_MIN_REPLICATION}" + ceph osd pool set $pool min_size "${RBD_POOL_MIN_REPLICATION}" fi done diff --git a/kubernetes/helm-charts/ceph-pools-audit/templates/job-ceph-pools-audit.yaml b/kubernetes/helm-charts/ceph-pools-audit/templates/job-ceph-pools-audit.yaml index df710892dc..eff2d4f12c 100644 --- a/kubernetes/helm-charts/ceph-pools-audit/templates/job-ceph-pools-audit.yaml +++ b/kubernetes/helm-charts/ceph-pools-audit/templates/job-ceph-pools-audit.yaml @@ -67,8 +67,8 @@ spec: value: {{ $tierConfig.replication | quote }} - name: RBD_POOL_MIN_REPLICATION value: {{ $tierConfig.min_replication | quote }} - - name: RBD_POOL_CRUSH_RULESET - value: {{ $tierConfig.crush_ruleset | quote }} + - name: RBD_POOL_CRUSH_RULE_NAME + value: {{ $tierConfig.crush_rule_name | quote }} command: - /tmp/ceph-pools-audit.sh volumeMounts: diff --git a/sysinv/sysinv/sysinv/sysinv/helm/ceph_pools_audit.py b/sysinv/sysinv/sysinv/sysinv/helm/ceph_pools_audit.py index c18490cffe..f68ddb3ad6 100644 --- a/sysinv/sysinv/sysinv/sysinv/helm/ceph_pools_audit.py +++ b/sysinv/sysinv/sysinv/sysinv/helm/ceph_pools_audit.py @@ -58,11 +58,11 @@ class CephPoolsAuditHelm(base.BaseHelm): # Tier config needed for the overrides. tier_cfg = { - "name": bk.name.encode('utf8', 'strict'), - "replication": int(bk.capabilities.get("replication")), - "min_replication": int(bk.capabilities.get("min_replication")), - "crush_ruleset": rule_name.encode('utf8', 'strict'), - } + "name": bk.name.encode('utf8', 'strict'), + "replication": int(bk.capabilities.get("replication")), + "min_replication": int(bk.capabilities.get("min_replication")), + "crush_rule_name": rule_name.encode('utf8', 'strict'), + } tiers_cfg.append(tier_cfg) overrides = {