[ceph-rgw] Add placement target delete support to RGW

A new "delete" value has been added to the ceph-rgw placement
target spec to allow existing placement targets to be deleted in a
brownfield deployment. For deployments where a deleted placement
target does not exist, the placement target will be created and
deleted in a single step.

Change-Id: I34e6d97543b63848b267332556b62d50d1865f49
This commit is contained in:
Stephen Taylor 2021-05-25 19:49:27 +00:00
parent 5b2e007d7a
commit 948e07e151
4 changed files with 22 additions and 1 deletions

View File

@ -15,6 +15,6 @@ apiVersion: v1
appVersion: v1.0.0
description: OpenStack-Helm Ceph RadosGW
name: ceph-rgw
version: 0.1.7
version: 0.1.8
home: https://github.com/ceph/ceph
...

View File

@ -23,6 +23,11 @@ function create_rgw_placement_target () {
--placement-id "$2"
}
function delete_rgw_placement_target () {
echo "Deleting rgw placement target $1"
radosgw-admin zonegroup placement rm $1
}
function add_rgw_zone_placement () {
echo "Adding rgw zone placement for placement target $2 data pool $3"
radosgw-admin zone placement add \
@ -33,6 +38,11 @@ function add_rgw_zone_placement () {
--data-extra-pool "$5"
}
function rm_rgw_zone_placement () {
echo "Removing rgw zone placement for placement target $1"
radosgw-admin zone placement rm $1
}
{{- range $i, $placement_target := .Values.conf.rgw_placement_targets }}
RGW_PLACEMENT_TARGET={{ $placement_target.name | quote }}
RGW_PLACEMENT_TARGET_DATA_POOL={{ $placement_target.data_pool | quote }}
@ -40,9 +50,15 @@ RGW_PLACEMENT_TARGET_INDEX_POOL={{ $placement_target.index_pool | default "defau
RGW_PLACEMENT_TARGET_DATA_EXTRA_POOL={{ $placement_target.data_extra_pool | default "default.rgw.buckets.non-ec" | quote }}
RGW_ZONEGROUP={{ $placement_target.zonegroup | default "default" | quote }}
RGW_ZONE={{ $placement_target.zone | default "default" | quote }}
RGW_DELETE_PLACEMENT_TARGET={{ $placement_target.delete | default "false" | quote }}
RGW_PLACEMENT_TARGET_EXISTS=$(radosgw-admin zonegroup placement get --placement-id "$RGW_PLACEMENT_TARGET" 2>/dev/null || true)
if [[ -z "$RGW_PLACEMENT_TARGET_EXISTS" ]]; then
create_rgw_placement_target "$RGW_ZONEGROUP" "$RGW_PLACEMENT_TARGET"
add_rgw_zone_placement "$RGW_ZONE" "$RGW_PLACEMENT_TARGET" "$RGW_PLACEMENT_TARGET_DATA_POOL" "$RGW_PLACEMENT_TARGET_INDEX_POOL" "$RGW_PLACEMENT_TARGET_DATA_EXTRA_POOL"
fi
if [[ -n "$RGW_PLACEMENT_TARGET_EXISTS" ]] &&
[[ "true" == "$RGW_DELETE_PLACEMENT_TARGET" ]]; then
rm_rgw_zone_placement "$RGW_PLACEMENT_TARGET"
delete_rgw_placement_target "$RGW_PLACEMENT_TARGET"
fi
{{- end }}

View File

@ -405,6 +405,10 @@ conf:
rgw_placement_targets:
- name: default-placement
data_pool: default.rgw.buckets.data
# Set 'delete' to true to delete an existing placement target. A
# non-existent placement target will be created and deleted in a single
# step.
# delete: true
rgw:
config:
# NOTE (portdirect): See http://tracker.ceph.com/issues/21226

View File

@ -8,4 +8,5 @@ ceph-rgw:
- 0.1.5 Add tls support
- 0.1.6 Update tls override options
- 0.1.7 Use ca cert for helm tests
- 0.1.8 Add placement target delete support to RGW
...