From 522785e05329d4aa3e2672826032d5bd9a8ad0de Mon Sep 17 00:00:00 2001 From: "J. Eric Ivancich" Date: Wed, 12 Jul 2023 13:54:07 -0400 Subject: [PATCH] rgw: allow multisite specification used w/ rgw-restore-bucket-index script When the metadata for a bucket is requested only the default realm/zonegroup/zone is currently supported. This adds three new command-line options to rgw-restore-bucket-index: -r -g -z The multisite specification will then be used in invocations of `radosgw-admin`, such as to query the zone, get metadata, and invoke the "object reindex" subcommand. Signed-off-by: J. Eric Ivancich --- doc/man/8/rgw-restore-bucket-index.rst | 15 +++++++++++ src/rgw/rgw-restore-bucket-index | 35 ++++++++++++++++++-------- 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/doc/man/8/rgw-restore-bucket-index.rst b/doc/man/8/rgw-restore-bucket-index.rst index b297fa753706..d721dd9702f7 100644 --- a/doc/man/8/rgw-restore-bucket-index.rst +++ b/doc/man/8/rgw-restore-bucket-index.rst @@ -56,6 +56,21 @@ Command-Line Arguments bucket. If omitted the utility will try to determine the data pool on its own. +.. option:: -r + + Optional, specify the realm if the restoration is not being applied + to the default realm. + +.. option:: -g + + Optional, specify the zonegroup if the restoration is not being applied + to the default zonegroup. + +.. option:: -z + + Optional, specify the zone if the restoration is not being applied + to the default zone. + .. option:: -l Optional, specify a file containing the output of a rados listing diff --git a/src/rgw/rgw-restore-bucket-index b/src/rgw/rgw-restore-bucket-index index f9269f55b13f..fffd5074dd45 100755 --- a/src/rgw/rgw-restore-bucket-index +++ b/src/rgw/rgw-restore-bucket-index @@ -97,12 +97,15 @@ usage() { Usage: $0 -b [-l ] [-p ] [-y] where: - -b Required - name of the bucket to operate on - -l Optional - file containing the output of 'rados ls -p ' - -p Optional - data pool; if not provided will be inferred from bucket and zone information - -y Optional - proceed with restoring without confirming with the user - USE WITH CAUTION. - -d Optional - run with debugging output + -b Required - name of the bucket to operate on + -l Optional - file containing the output of 'rados ls -p ' + -r Optional - specify the realm if not applying to the default realm" + -g Optional - specify the zonegroup if not applying to the default zonegroup" + -z Optional - specify the zone if not applying to the default zone" + -p Optional - data pool; if not provided will be inferred from bucket and zone information + -y Optional - proceed with restoring without confirming with the user + USE WITH CAUTION. + -d Optional - run with debugging output EOF super_exit } @@ -128,7 +131,7 @@ get_pool() { plmt_class=STANDARD fi - radosgw-admin zone get >$zone_info 2>/dev/null + radosgw-admin zone get $multisite_spec >$zone_info 2>/dev/null pool=$(jq -r ".placement_pools [] | select(.key | contains(\"${plmt_pool}\")) .val .storage_classes.${plmt_class}.data_pool" $zone_info) if [ -z "$pool" ] ;then @@ -140,10 +143,11 @@ get_pool() { export bucket="" pool="" +multisite_spec="" lsoutput="" debug=0 -while getopts "b:l:p:yd" o; do +while getopts "b:l:p:r:g:z:yd" o; do case "${o}" in b) bucket="${OPTARG}" @@ -160,6 +164,15 @@ while getopts "b:l:p:yd" o; do p) pool="${OPTARG}" ;; + r) + multisite_spec="$multisite_spec --rgw-realm=${OPTARG}" + ;; + g) + multisite_spec="$multisite_spec --rgw-zonegroup=${OPTARG}" + ;; + z) + multisite_spec="$multisite_spec --rgw-zone=${OPTARG}" + ;; y) echo "NOTICE: This tool is currently considered EXPERIMENTAL." proceed=1 @@ -236,7 +249,7 @@ if [ -z "$bucket" ]; then fi # read bucket entry metadata -eval "radosgw-admin metadata get bucket:$bucket $debugging_rgwadmin >$bkt_entry" +eval "radosgw-admin metadata get bucket:$bucket $debugging_rgwadmin $multisite_spec >$bkt_entry" export marker=$(jq -r ".data.bucket.marker" $bkt_entry) export bucket_id=$(jq -r ".data.bucket.bucket_id" $bkt_entry) if [ -z "$marker" -o -z "$bucket_id" ] ;then @@ -249,7 +262,7 @@ echo marker is $marker echo bucket_id is $bucket_id # read bucket instance metadata -eval "radosgw-admin metadata get bucket.instance:${bucket}:$bucket_id $debugging_rgwadmin >$bkt_inst" +eval "radosgw-admin metadata get bucket.instance:${bucket}:$bucket_id $multisite_spec $debugging_rgwadmin >$bkt_inst" # examine number of bucket index shards num_shards=$(jq ".data.bucket_info.num_shards" $bkt_inst) @@ -326,7 +339,7 @@ if [ -z "$proceed" ] ;then done fi -eval "radosgw-admin object reindex --bucket=$bucket --objects-file=$obj_list_ver --yes-i-really-mean-it $debugging_rgwadmin" +eval "radosgw-admin object reindex --bucket=$bucket --objects-file=$obj_list_ver $multisite_spec --yes-i-really-mean-it $debugging_rgwadmin" clean echo Done