From dcdd4a5d0ef5666c53c02a69c12597a56d89c5c5 Mon Sep 17 00:00:00 2001
From: Chinasubbareddy Mallavarapu <cr3938@att.com>
Date: Mon, 2 Mar 2020 13:46:37 -0600
Subject: [PATCH] [ceph-pools] Stop setting pgp_num to nautilus based
 deployments

Starting in Nautilus, setting pgp_num step is no longer necessary
as long as pgp_num and pg_num currently match, pgp_num will automatically
track any pg_num changes.
More importantly, the adjustment of pgp_num to migrate data and (eventually)
converge to pg_num is done gradually to limit the data migration load on the system.

Change-Id: I2e3c9bd1fada8105fbf4e095a78db63c4ba80825
---
 ceph-client/templates/bin/pool/_init.sh.tpl | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/ceph-client/templates/bin/pool/_init.sh.tpl b/ceph-client/templates/bin/pool/_init.sh.tpl
index e751ed693..b5688230e 100644
--- a/ceph-client/templates/bin/pool/_init.sh.tpl
+++ b/ceph-client/templates/bin/pool/_init.sh.tpl
@@ -107,12 +107,17 @@ function create_pool () {
 #
   ceph --cluster "${CLUSTER}" osd pool set "${POOL_NAME}" size ${POOL_REPLICATION}
   ceph --cluster "${CLUSTER}" osd pool set "${POOL_NAME}" crush_rule "${POOL_CRUSH_RULE}"
-  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 }")
-    if [ "${POOL_PLACEMENT_GROUPS}" -gt "${CURRENT_PG_VALUE}" ]; then
-      ceph --cluster "${CLUSTER}" osd pool set "${POOL_NAME}" "${PG_PARAM}" "${POOL_PLACEMENT_GROUPS}"
-    fi
-  done
+# set pg_num to pool
+  if [[ -z "$(ceph osd versions | grep ceph\ version | grep -v nautilus)" ]]; then
+    ceph --cluster "${CLUSTER}" osd pool set "${POOL_NAME}" "pg_num" "${POOL_PLACEMENT_GROUPS}"
+  else
+    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 }")
+      if [ "${POOL_PLACEMENT_GROUPS}" -gt "${CURRENT_PG_VALUE}" ]; then
+        ceph --cluster "${CLUSTER}" osd pool set "${POOL_NAME}" "${PG_PARAM}" "${POOL_PLACEMENT_GROUPS}"
+      fi
+    done
+  fi
 
 #This is to handle cluster expansion case where replication may change from intilization
   if [ ${POOL_REPLICATION} -gt 1 ]; then