From 699ea1acbaf4eb1682539b2e8a0e2e594e333091 Mon Sep 17 00:00:00 2001 From: bw6938 Date: Thu, 28 Nov 2019 03:28:13 +0000 Subject: [PATCH] [ceph-client] Validate failure domain support for replica count per pool Ensure each pool is configured with enough failure domains to satisfy the pool's replica size requirements. If any pool does not have enough failure domains to satisfy the pool's replica size, then fail the ceph deployment. Change-Id: I9dd1cafd05e81f145d1eb8c916591203946bc8f1 --- ceph-client/templates/bin/_helm-tests.sh.tpl | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ceph-client/templates/bin/_helm-tests.sh.tpl b/ceph-client/templates/bin/_helm-tests.sh.tpl index d3fe6ecdc..757c725cb 100755 --- a/ceph-client/templates/bin/_helm-tests.sh.tpl +++ b/ceph-client/templates/bin/_helm-tests.sh.tpl @@ -51,6 +51,24 @@ function check_osd_count() { fi } +function check_failure_domain_count_per_pool() { + echo "#### Start: Checking failure domain count per pool ####" + pools=$(ceph osd pool ls) + for pool in ${pools} + do + crush_rule=$(ceph osd pool get ${pool} crush_rule | awk '{print $2}') + bucket_type=$(ceph osd crush rule dump ${crush_rule} | grep '"type":' | awk -F'"' 'NR==2 {print $4}') + num_failure_domains=$(ceph osd tree | grep ${bucket_type} | wc -l) + pool_replica_size=$(ceph osd pool get ${pool} size | awk '{print $2}') + if [[ ${num_failure_domains} -ge ${pool_replica_size} ]]; then + echo "--> Info: Pool ${pool} is configured with enough failure domains ${num_failure_domains} to satisfy pool replica size ${pool_replica_size}" + else + echo "--> Error : Pool ${pool} is NOT configured with enough failure domains ${num_failure_domains} to satisfy pool replica size ${pool_replica_size}" + exit 1 + fi + done +} + function mgr_validation() { echo "#### Start: MGR validation ####" mgr_dump=$(ceph mgr dump -f json-pretty) @@ -202,7 +220,9 @@ OSD_POOLS_DETAILS=$(ceph osd pool ls detail -f json-pretty) OSD_CRUSH_RULE_DUMP=$(ceph osd crush rule dump -f json-pretty) PG_STAT=$(ceph pg stat -f json-pretty) + pg_validation pool_validation pool_failuredomain_validation +check_failure_domain_count_per_pool check_cluster_status