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 <robert.church@windriver.com>
This commit is contained in:
Robert Church 2019-05-12 00:32:06 -04:00
parent 95b946469a
commit f0d520105d
3 changed files with 31 additions and 40 deletions

View File

@ -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

View File

@ -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:

View File

@ -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 = {