diff --git a/ceph-client/templates/bin/pool/_init.sh.tpl b/ceph-client/templates/bin/pool/_init.sh.tpl index 3d1df84b0..315b3b7d9 100644 --- a/ceph-client/templates/bin/pool/_init.sh.tpl +++ b/ceph-client/templates/bin/pool/_init.sh.tpl @@ -77,8 +77,10 @@ function reweight_osds () { } function enable_autoscaling () { - ceph mgr module enable pg_autoscaler - ceph config set global osd_pool_default_pg_autoscale_mode on + if [[ "${ENABLE_AUTOSCALER}" == "true" ]]; then + ceph mgr module enable pg_autoscaler + ceph config set global osd_pool_default_pg_autoscale_mode on + fi } function create_pool () { @@ -93,7 +95,7 @@ function create_pool () { while [ $(ceph --cluster "${CLUSTER}" -s | grep creating -c) -gt 0 ]; do echo -n .;sleep 1; done ceph --cluster "${CLUSTER}" osd pool application enable "${POOL_NAME}" "${POOL_APPLICATION}" else - if [[ -z "$(ceph osd versions | grep ceph\ version | grep -v nautilus)" ]]; then + if [[ -z "$(ceph osd versions | grep ceph\ version | grep -v nautilus)" ]] && [[ $"{ENABLE_AUTOSCALER}" == "true" ]] ; then ceph --cluster "${CLUSTER}" osd pool set "${POOL_NAME}" pg_autoscale_mode on fi fi @@ -155,13 +157,7 @@ function manage_pool () { POOL_PROTECTION=$8 CLUSTER_CAPACITY=$9 TOTAL_OSDS={{.Values.conf.pool.target.osd}} - # This is a workaround for a pg merging bug in ceph. The only reason this works is because the - # 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 + POOL_PLACEMENT_GROUPS=$(/tmp/pool-calc.py ${POOL_REPLICATION} ${TOTAL_OSDS} ${TOTAL_DATA_PERCENT} ${TARGET_PG_PER_OSD}) 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_QUOTA=$(python -c "print(int($CLUSTER_CAPACITY * $TOTAL_DATA_PERCENT * $TARGET_QUOTA / $POOL_REPLICAS / 100 / 100))") diff --git a/ceph-client/templates/job-rbd-pool.yaml b/ceph-client/templates/job-rbd-pool.yaml index 55a3f77e0..1ab0c0ac9 100644 --- a/ceph-client/templates/job-rbd-pool.yaml +++ b/ceph-client/templates/job-rbd-pool.yaml @@ -52,6 +52,8 @@ spec: env: - name: CLUSTER value: "ceph" + - name: ENABLE_AUTOSCALER + value: {{ .Values.conf.features.pg_autoscaler | quote }} command: - /tmp/pool-init.sh volumeMounts: diff --git a/ceph-client/values.yaml b/ceph-client/values.yaml index e5f788890..7d9009147 100644 --- a/ceph-client/values.yaml +++ b/ceph-client/values.yaml @@ -230,6 +230,7 @@ conf: features: mds: true mgr: true + pg_autoscaler: true pool: #NOTE(portdirect): this drives a simple approximation of # https://ceph.com/pgcalc/, the `target.osd` key should be set to match the