[ceph-client] Set num PGs to small value for a pg autoscaling bug

This is to workaround a pg merging bug in ceph. The number of PGs
is set to a small value. The reason this works is because the
pg autoscaler is set to work unconditionally. This will need
to change once the autoscaler is optional.

Change-Id: I6ec404f281e201023fa974601d7083f4ce3cfd30
This commit is contained in:
Wickersham, Brian (bw6938) 2020-03-25 18:08:33 +00:00
parent 344440ef27
commit b607f8654b

View File

@ -85,11 +85,9 @@ function create_pool () {
POOL_APPLICATION=$1 POOL_APPLICATION=$1
POOL_NAME=$2 POOL_NAME=$2
POOL_REPLICATION=$3 POOL_REPLICATION=$3
TOTAL_DATA_PERCENT=$4 POOL_PLACEMENT_GROUPS=$4
POOL_PLACEMENT_GROUPS=$5 POOL_CRUSH_RULE=$5
POOL_CRUSH_RULE=$6 POOL_PROTECTION=$6
POOL_PROTECTION=$7
TARGET_SIZE_RATIO=$(python -c "print((float($TOTAL_DATA_PERCENT) / 100.0))")
if ! ceph --cluster "${CLUSTER}" osd pool stats "${POOL_NAME}" > /dev/null 2>&1; then if ! ceph --cluster "${CLUSTER}" osd pool stats "${POOL_NAME}" > /dev/null 2>&1; then
ceph --cluster "${CLUSTER}" osd pool create "${POOL_NAME}" ${POOL_PLACEMENT_GROUPS} ceph --cluster "${CLUSTER}" osd pool create "${POOL_NAME}" ${POOL_PLACEMENT_GROUPS}
while [ $(ceph --cluster "${CLUSTER}" -s | grep creating -c) -gt 0 ]; do echo -n .;sleep 1; done while [ $(ceph --cluster "${CLUSTER}" -s | grep creating -c) -gt 0 ]; do echo -n .;sleep 1; done
@ -111,7 +109,7 @@ function create_pool () {
ceph --cluster "${CLUSTER}" osd pool set "${POOL_NAME}" crush_rule "${POOL_CRUSH_RULE}" ceph --cluster "${CLUSTER}" osd pool set "${POOL_NAME}" crush_rule "${POOL_CRUSH_RULE}"
# set pg_num to pool # set pg_num to pool
if [[ -z "$(ceph osd versions | grep ceph\ version | grep -v nautilus)" ]]; then if [[ -z "$(ceph osd versions | grep ceph\ version | grep -v nautilus)" ]]; then
ceph --cluster "${CLUSTER}" osd pool set "${POOL_NAME}" target_size_ratio "${TARGET_SIZE_RATIO}" ceph --cluster "${CLUSTER}" osd pool set "${POOL_NAME}" "pg_num" "${POOL_PLACEMENT_GROUPS}"
else else
for PG_PARAM in pg_num pgp_num; do for PG_PARAM in pg_num pgp_num; do
CURRENT_PG_VALUE=$(ceph --cluster "${CLUSTER}" osd pool get "${POOL_NAME}" "${PG_PARAM}" | awk "/^${PG_PARAM}:/ { print \$NF }") CURRENT_PG_VALUE=$(ceph --cluster "${CLUSTER}" osd pool get "${POOL_NAME}" "${PG_PARAM}" | awk "/^${PG_PARAM}:/ { print \$NF }")
@ -157,8 +155,14 @@ function manage_pool () {
POOL_PROTECTION=$8 POOL_PROTECTION=$8
CLUSTER_CAPACITY=$9 CLUSTER_CAPACITY=$9
TOTAL_OSDS={{.Values.conf.pool.target.osd}} TOTAL_OSDS={{.Values.conf.pool.target.osd}}
POOL_PLACEMENT_GROUPS=$(/tmp/pool-calc.py ${POOL_REPLICATION} ${TOTAL_OSDS} ${TOTAL_DATA_PERCENT} ${TARGET_PG_PER_OSD}) # This is a workaround for a pg merging bug in ceph. The only reason this works is because the
create_pool "${POOL_APPLICATION}" "${POOL_NAME}" "${POOL_REPLICATION}" "${TOTAL_DATA_PERCENT}" "${POOL_PLACEMENT_GROUPS}" "${POOL_CRUSH_RULE}" "${POOL_PROTECTION}" # autoscaler is set to work unconditionally. This needs to change once the autoscaler is optional.
if [[ -z "$(ceph osd versions | grep ceph\ version | grep -v nautilus)" ]]; then
POOL_PLACEMENT_GROUPS=4
else
POOL_PLACEMENT_GROUPS=$(/tmp/pool-calc.py ${POOL_REPLICATION} ${TOTAL_OSDS} ${TOTAL_DATA_PERCENT} ${TARGET_PG_PER_OSD})
fi
create_pool "${POOL_APPLICATION}" "${POOL_NAME}" "${POOL_REPLICATION}" "${POOL_PLACEMENT_GROUPS}" "${POOL_CRUSH_RULE}" "${POOL_PROTECTION}"
POOL_REPLICAS=$(ceph --cluster "${CLUSTER}" osd pool get "${POOL_NAME}" size | awk '{print $2}') POOL_REPLICAS=$(ceph --cluster "${CLUSTER}" osd pool get "${POOL_NAME}" size | awk '{print $2}')
POOL_QUOTA=$(python -c "print(int($CLUSTER_CAPACITY * $TOTAL_DATA_PERCENT * $TARGET_QUOTA / $POOL_REPLICAS / 100 / 100))") POOL_QUOTA=$(python -c "print(int($CLUSTER_CAPACITY * $TOTAL_DATA_PERCENT * $TARGET_QUOTA / $POOL_REPLICAS / 100 / 100))")
ceph --cluster "${CLUSTER}" osd pool set-quota "${POOL_NAME}" max_bytes $POOL_QUOTA ceph --cluster "${CLUSTER}" osd pool set-quota "${POOL_NAME}" max_bytes $POOL_QUOTA