From 46beb87574160b51818e66621d3222c08e24520c Mon Sep 17 00:00:00 2001
From: Stephen Taylor <stephen.taylor.1@att.com>
Date: Wed, 15 Mar 2023 07:10:10 -0600
Subject: [PATCH] Allow Ceph pools to use 1x replication

Beginning with the Pacific release, Ceph pools are not allowed to
use 1x replication by default. This is problematic for the
openstack-helm gate scripts, which frequently use 1x replication
for automated testing. This change adds Ceph configuration and
command overrides to allow those gate scripts to continue to use
1x replication for testing.

Change-Id: I21ed3e43f3773d5ea830959f1b66b35f38185ca7
---
 cinder/Chart.yaml                                   | 2 +-
 cinder/templates/bin/_backup-storage-init.sh.tpl    | 2 +-
 cinder/templates/bin/_storage-init.sh.tpl           | 2 +-
 glance/Chart.yaml                                   | 2 +-
 glance/templates/bin/_storage-init.sh.tpl           | 2 +-
 releasenotes/notes/cinder.yaml                      | 1 +
 releasenotes/notes/glance.yaml                      | 1 +
 tools/deployment/component/ceph/ceph-ns-activate.sh | 1 +
 tools/deployment/component/ceph/ceph.sh             | 1 +
 tools/deployment/multinode/030-ceph.sh              | 1 +
 10 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/cinder/Chart.yaml b/cinder/Chart.yaml
index 89c0330ce3..e3afc22c37 100644
--- a/cinder/Chart.yaml
+++ b/cinder/Chart.yaml
@@ -14,7 +14,7 @@ apiVersion: v1
 appVersion: v1.0.0
 description: OpenStack-Helm Cinder
 name: cinder
-version: 0.3.6
+version: 0.3.7
 home: https://docs.openstack.org/cinder/latest/
 icon: https://www.openstack.org/themes/openstack/images/project-mascots/Cinder/OpenStack_Project_Cinder_vertical.png
 sources:
diff --git a/cinder/templates/bin/_backup-storage-init.sh.tpl b/cinder/templates/bin/_backup-storage-init.sh.tpl
index cd2389c211..a50ecb74cf 100644
--- a/cinder/templates/bin/_backup-storage-init.sh.tpl
+++ b/cinder/templates/bin/_backup-storage-init.sh.tpl
@@ -37,7 +37,7 @@ elif [[ $STORAGE_BACKEND =~ 'cinder.backup.drivers.ceph' ]]; then
     fi
     size_protection=$(ceph osd pool get $1 nosizechange | cut -f2 -d: | tr -d '[:space:]')
     ceph osd pool set $1 nosizechange 0
-    ceph osd pool set $1 size ${RBD_POOL_REPLICATION}
+    ceph osd pool set $1 size ${RBD_POOL_REPLICATION} --yes-i-really-mean-it
     ceph osd pool set $1 nosizechange ${size_protection}
     ceph osd pool set $1 crush_rule "${RBD_POOL_CRUSH_RULE}"
   }
diff --git a/cinder/templates/bin/_storage-init.sh.tpl b/cinder/templates/bin/_storage-init.sh.tpl
index a43115e423..4f945e2cd6 100644
--- a/cinder/templates/bin/_storage-init.sh.tpl
+++ b/cinder/templates/bin/_storage-init.sh.tpl
@@ -34,7 +34,7 @@ if [ "x$STORAGE_BACKEND" == "xcinder.volume.drivers.rbd.RBDDriver" ]; then
     fi
     size_protection=$(ceph osd pool get $1 nosizechange | cut -f2 -d: | tr -d '[:space:]')
     ceph osd pool set $1 nosizechange 0
-    ceph osd pool set $1 size ${RBD_POOL_REPLICATION}
+    ceph osd pool set $1 size ${RBD_POOL_REPLICATION} --yes-i-really-mean-it
     ceph osd pool set $1 nosizechange ${size_protection}
     ceph osd pool set $1 crush_rule "${RBD_POOL_CRUSH_RULE}"
   }
diff --git a/glance/Chart.yaml b/glance/Chart.yaml
index 7ce28411a1..e0faed51a5 100644
--- a/glance/Chart.yaml
+++ b/glance/Chart.yaml
@@ -14,7 +14,7 @@ apiVersion: v1
 appVersion: v1.0.0
 description: OpenStack-Helm Glance
 name: glance
-version: 0.4.1
+version: 0.4.2
 home: https://docs.openstack.org/glance/latest/
 icon: https://www.openstack.org/themes/openstack/images/project-mascots/Glance/OpenStack_Project_Glance_vertical.png
 sources:
diff --git a/glance/templates/bin/_storage-init.sh.tpl b/glance/templates/bin/_storage-init.sh.tpl
index cf6fecbf13..0d291fd29a 100644
--- a/glance/templates/bin/_storage-init.sh.tpl
+++ b/glance/templates/bin/_storage-init.sh.tpl
@@ -49,7 +49,7 @@ elif [ "x$STORAGE_BACKEND" == "xrbd" ]; then
     if [[ $(ceph mgr versions | awk '/version/{print $3}' | cut -d. -f1) -ge 12 ]]; then
         ceph osd pool application enable $1 $3
     fi
-    ceph osd pool set "$1" size "${RBD_POOL_REPLICATION}"
+    ceph osd pool set "$1" size "${RBD_POOL_REPLICATION}" --yes-i-really-mean-it
     ceph osd pool set "$1" crush_rule "${RBD_POOL_CRUSH_RULE}"
   }
   ensure_pool "${RBD_POOL_NAME}" "${RBD_POOL_CHUNK_SIZE}" "${RBD_POOL_APP_NAME}"
diff --git a/releasenotes/notes/cinder.yaml b/releasenotes/notes/cinder.yaml
index 1df52d5bbb..0a20ac69d2 100644
--- a/releasenotes/notes/cinder.yaml
+++ b/releasenotes/notes/cinder.yaml
@@ -56,4 +56,5 @@ cinder:
   - 0.3.4 Fix Helm hooks for storage bootstrap jobs
   - 0.3.5 Add Nova endpoint details to support online volume resize
   - 0.3.6 Fix ceph keyring placement for uppercased backends
+  - 0.3.7 Allow Ceph pools to use 1x replication
 ...
diff --git a/releasenotes/notes/glance.yaml b/releasenotes/notes/glance.yaml
index 6998bff3ab..4361a45442 100644
--- a/releasenotes/notes/glance.yaml
+++ b/releasenotes/notes/glance.yaml
@@ -35,4 +35,5 @@ glance:
   - 0.3.12 Add support for using Cinder as backend
   - 0.4.0 Remove support for Train and Ussuri
   - 0.4.1 Remove default policy rules
+  - 0.4.2 Allow Ceph pools to use 1x replication
 ...
diff --git a/tools/deployment/component/ceph/ceph-ns-activate.sh b/tools/deployment/component/ceph/ceph-ns-activate.sh
index 09640b612b..9574d4f0fd 100755
--- a/tools/deployment/component/ceph/ceph-ns-activate.sh
+++ b/tools/deployment/component/ceph/ceph-ns-activate.sh
@@ -41,6 +41,7 @@ conf:
   ceph:
     global:
       mon_host: ceph-mon-discovery.ceph.svc.cluster.local:6789
+      mon_allow_pool_size_one: true
 EOF
 helm upgrade --install ceph-openstack-config ${HELM_CHART_ROOT_PATH}/ceph-provisioners \
   --namespace=openstack \
diff --git a/tools/deployment/component/ceph/ceph.sh b/tools/deployment/component/ceph/ceph.sh
index 0f8f8a008e..face952145 100755
--- a/tools/deployment/component/ceph/ceph.sh
+++ b/tools/deployment/component/ceph/ceph.sh
@@ -67,6 +67,7 @@ conf:
     global:
       fsid: ${CEPH_FS_ID}
       mon_addr: :6789
+      mon_allow_pool_size_one: true
       osd_pool_default_size: 1
     osd:
       osd_crush_chooseleaf_type: 0
diff --git a/tools/deployment/multinode/030-ceph.sh b/tools/deployment/multinode/030-ceph.sh
index be5d5cff48..54d9f1c30e 100755
--- a/tools/deployment/multinode/030-ceph.sh
+++ b/tools/deployment/multinode/030-ceph.sh
@@ -48,6 +48,7 @@ conf:
   ceph:
     global:
       fsid: ${CEPH_FS_ID}
+      mon_allow_pool_size_one: true
   pool:
     crush:
       tunables: ${CRUSH_TUNABLES}