From f66f9fe560d1a6057e82ec7cf1f01e33284be2bd Mon Sep 17 00:00:00 2001 From: "Taylor, Stephen (st053q)" Date: Thu, 13 Aug 2020 12:00:32 -0600 Subject: [PATCH] [ceph-client] Fix crush weight comparison in reweight_osds() The recently-added crush weight comparison in reweight_osds() that checks weights for zero isn't working correctly because the expected weight is being calculated to two decimal places and then compared against "0" as a string. This updates the comparison string to "0.00" to match the calculation. Change-Id: I29387a597a21180bb7fba974b4daeadf6ffc182d --- ceph-client/templates/bin/pool/_init.sh.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ceph-client/templates/bin/pool/_init.sh.tpl b/ceph-client/templates/bin/pool/_init.sh.tpl index b29975d10..aed81bf72 100644 --- a/ceph-client/templates/bin/pool/_init.sh.tpl +++ b/ceph-client/templates/bin/pool/_init.sh.tpl @@ -139,7 +139,7 @@ function reweight_osds () { for OSD_ID in $(ceph --cluster "${CLUSTER}" osd ls); do OSD_EXPECTED_WEIGHT=$(echo "${OSD_DF_OUTPUT}" | grep -A7 "\bosd.${OSD_ID}\b" | awk '/"kb"/{ gsub(",",""); d= $2/1073741824 ; r = sprintf("%.2f", d); print r }'); OSD_WEIGHT=$(echo "${OSD_DF_OUTPUT}" | grep -A3 "\bosd.${OSD_ID}\b" | awk '/crush_weight/{print $2}' | cut -d',' -f1) - if [[ "${OSD_EXPECTED_WEIGHT}" != "0" ]] && [[ "${OSD_WEIGHT}" != "${OSD_EXPECTED_WEIGHT}" ]]; then + if [[ "${OSD_EXPECTED_WEIGHT}" != "0.00" ]] && [[ "${OSD_WEIGHT}" != "${OSD_EXPECTED_WEIGHT}" ]]; then ceph --cluster "${CLUSTER}" osd crush reweight osd.${OSD_ID} ${OSD_EXPECTED_WEIGHT}; fi done