Merge "Fix ceph-pools-audit chart for Ceph Mimic"

This commit is contained in:
Zuul 2019-06-04 18:25:00 +00:00 committed by Gerrit Code Review
commit 43e0401fa1
2 changed files with 26 additions and 35 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: