[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
This commit is contained in:
Stephen Taylor 2021-05-24 19:13:17 +00:00
parent 9111ae750e
commit bcc31f9821
4 changed files with 20 additions and 1 deletions

View File

@ -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
...

View File

@ -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 }}

View File

@ -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

View File

@ -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
...