From bcc31f98218192f059b7209dcea407c2c681a1c5 Mon Sep 17 00:00:00 2001 From: Stephen Taylor Date: Mon, 24 May 2021 19:13:17 +0000 Subject: [PATCH] [ceph-client] Add pool delete support for Ceph pools Two new values, "delete" and "delete_all_pool_data," have been added to the Ceph pool spec to allow existing pools to be deleted in a brownfield deployment. For deployments where a pool does not exist, either for greenfield or because it has been deleted previously, the pool will be created and then deleted in a single step. Change-Id: Ic22acf02ae2e02e03b834e187d8a6a1fa58249e7 --- ceph-client/Chart.yaml | 2 +- ceph-client/templates/bin/pool/_init.sh.tpl | 11 +++++++++++ ceph-client/values.yaml | 7 +++++++ releasenotes/notes/ceph-client.yaml | 1 + 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/ceph-client/Chart.yaml b/ceph-client/Chart.yaml index af7eaeab1..a33d2f53d 100644 --- a/ceph-client/Chart.yaml +++ b/ceph-client/Chart.yaml @@ -15,6 +15,6 @@ apiVersion: v1 appVersion: v1.0.0 description: OpenStack-Helm Ceph Client name: ceph-client -version: 0.1.17 +version: 0.1.18 home: https://github.com/ceph/ceph-client ... diff --git a/ceph-client/templates/bin/pool/_init.sh.tpl b/ceph-client/templates/bin/pool/_init.sh.tpl index 0e68adab4..93183e010 100644 --- a/ceph-client/templates/bin/pool/_init.sh.tpl +++ b/ceph-client/templates/bin/pool/_init.sh.tpl @@ -345,6 +345,17 @@ manage_pool {{ .application }} ${pool_name} {{ .replication }} {{ .percent_total if [[ -n "$(ceph --cluster ${CLUSTER} osd pool ls | grep ^{{ .name }}$)" ]] && [[ -z "$(ceph --cluster ${CLUSTER} osd pool ls | grep ^{{ .rename }}$)" ]]; then ceph --cluster "${CLUSTER}" osd pool rename "{{ .name }}" "{{ .rename }}" + pool_name="{{ .rename }}" +fi +{{- end }} +{{- if and .delete .delete_all_pool_data }} +# If delete is set to true and delete_all_pool_data is also true, delete the pool +if [[ "true" == "{{ .delete }}" ]] && + [[ "true" == "{{ .delete_all_pool_data }}" ]]; then + ceph --cluster "${CLUSTER}" tell mon.* injectargs '--mon-allow-pool-delete=true' + ceph --cluster "${CLUSTER}" osd pool set "${pool_name}" nodelete false + ceph --cluster "${CLUSTER}" osd pool delete "${pool_name}" "${pool_name}" --yes-i-really-really-mean-it + ceph --cluster "${CLUSTER}" tell mon.* injectargs '--mon-allow-pool-delete=false' fi {{- end }} {{- end }} diff --git a/ceph-client/values.yaml b/ceph-client/values.yaml index 08987fd37..74a6a0eb9 100644 --- a/ceph-client/values.yaml +++ b/ceph-client/values.yaml @@ -354,6 +354,13 @@ conf: # renamed, the name will not be changed. If two pools exist with the two names, the # pool matching the renamed value will be configured and the other left alone. # rename: rbd-new + # Optional "delete" and "delete_all_pool_data" values may be used to delete an + # existing pool. Both must exist and must be set to true in order to delete a pool. + # NOTE: Deleting a pool deletes all of its data and is unrecoverable. This is why + # both values are required in order to delete a pool. Neither value does + # anything by itself. + # delete: false + # delete_all_pool_data: false application: rbd replication: 3 percent_total_data: 40 diff --git a/releasenotes/notes/ceph-client.yaml b/releasenotes/notes/ceph-client.yaml index c7b0a3af5..5c070cb8f 100644 --- a/releasenotes/notes/ceph-client.yaml +++ b/releasenotes/notes/ceph-client.yaml @@ -18,4 +18,5 @@ ceph-client: - 0.1.15 Make ceph-client helm test more PG specific - 0.1.16 Make Ceph pool init job consistent with helm test - 0.1.17 Add pool rename support for Ceph pools + - 0.1.18 Add pool delete support for Ceph pools ...