]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: allow multisite specification used w/ rgw-restore-bucket-index script
authorJ. Eric Ivancich <ivancich@redhat.com>
Wed, 12 Jul 2023 17:54:07 +0000 (13:54 -0400)
committerJ. Eric Ivancich <ivancich@redhat.com>
Wed, 30 Aug 2023 18:41:15 +0000 (14:41 -0400)
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 <realm-name>
    -g <zonegroup-name>
    -z <zone-name>

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 <ivancich@redhat.com>
doc/man/8/rgw-restore-bucket-index.rst
src/rgw/rgw-restore-bucket-index

index b297fa7537065e99714231330d5a48ffbc9498ca..d721dd9702f7ce522246a9dfb2fbaead6d6b989b 100644 (file)
@@ -56,6 +56,21 @@ Command-Line Arguments
    bucket. If omitted the utility will try to determine the data pool
    on its own.
 
+.. option:: -r <realm-name>
+
+   Optional, specify the realm if the restoration is not being applied
+   to the default realm.
+
+.. option:: -g <zonegroup-name>
+
+   Optional, specify the zonegroup if the restoration is not being applied
+   to the default zonegroup.
+
+.. option:: -z <zone-name>
+
+   Optional, specify the zone if the restoration is not being applied
+   to the default zone.
+
 .. option:: -l <rados-ls-output-file>
 
    Optional, specify a file containing the output of a rados listing
index f9269f55b13f1a098ef22d702a5a44ffc8cabf66..fffd5074dd456cab3a7f7eda39f492c37ddbd8c2 100755 (executable)
@@ -97,12 +97,15 @@ usage() {
 Usage: $0 -b <bucketname> [-l <rados-ls-file>] [-p <pool>] [-y]
 
 where:
-  -b <bucketname>     Required - name of the bucket to operate on
-  -l <rados-ls-file>  Optional - file containing the output of 'rados ls -p <pool>'
-  -p <pool>           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 <bucketname>      Required - name of the bucket to operate on
+  -l <rados-ls-file>   Optional - file containing the output of 'rados ls -p <pool>'
+  -r <realm-name>      Optional - specify the realm if not applying to the default realm"
+  -g <zonegroup-name>  Optional - specify the zonegroup if not applying to the default zonegroup"
+  -z <zone-name>       Optional - specify the zone if not applying to the default zone"
+  -p <pool>            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