]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: allow reshard log entries for non-existent buckets to be cancelled 33302/head
authorJ. Eric Ivancich <ivancich@redhat.com>
Tue, 29 Oct 2019 23:25:51 +0000 (19:25 -0400)
committerNathan Cutler <ncutler@suse.com>
Fri, 14 Feb 2020 09:48:35 +0000 (10:48 +0100)
The radosgw-admin tool allows admins to add buckets to the reshard log
and to cancel buckets from the reshard log. Both operations check for
the existence of the bucket before proceeding and fail for nonexistent
buckets.

It's possible, however, for an admin to add a bucket to the reshard
log and then, before the bucket is resharded, for a user to delete the
bucket. This leaves the entry in the reshard log.

Prior to this commit an attempt to use radosgw-admin to cancel the
reshard log entry would fail. With this commit it will still fail
*but* notify the user they can use the --yes-i-really-mean-it
command-line option to do it nonetheless. And if the user includes
that option, it will succeed.

Signed-off-by: J. Eric Ivancich <ivancich@redhat.com>
(cherry picked from commit 9f893a7398716127711a0baaa937070a495a7a56)

Conflicts:
src/rgw/rgw_admin.cc
- mimic has "g_conf->rgw_reshard_bucket_lock_duration" where master has
  store->ctx()->_conf.get_val<uint64_t>("rgw_reshard_bucket_lock_duration")

src/rgw/rgw_admin.cc

index 367bf746514d8fc73b65e8b2c018f577f54da69e..0172582ca10bb37304de2e755b47e25c2d95042b 100644 (file)
@@ -6309,24 +6309,38 @@ next:
     rgw_bucket bucket;
     RGWBucketInfo bucket_info;
     map<string, bufferlist> attrs;
-    ret = init_bucket(tenant, bucket_name, bucket_id, bucket_info, bucket, &attrs);
+    bool bucket_initable = true;
+    ret = init_bucket(tenant, bucket_name, bucket_id, bucket_info, bucket,
+                      &attrs);
     if (ret < 0) {
-      cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl;
-      return -ret;
+      if (yes_i_really_mean_it) {
+        bucket_initable = false;
+      } else {
+        cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) <<
+          "; if you want to cancel the reshard request nonetheless, please "
+          "use the --yes-i-really-mean-it option" << std::endl;
+        return -ret;
+      }
     }
 
-    RGWBucketReshard br(store, bucket_info, attrs, nullptr /* no callback */);
-    int ret = br.cancel();
-    if (ret < 0) {
-      if (ret == -EBUSY) {
-       cerr << "There is ongoing resharding, please retry after " << g_conf->rgw_reshard_bucket_lock_duration <<
-            " seconds " << std::endl;
-      } else {
-       cerr << "Error canceling bucket " << bucket_name << " resharding: " << cpp_strerror(-ret) <<
-         std::endl;
+    if (bucket_initable) {
+      // we did not encounter an error, so let's work with the bucket
+      RGWBucketReshard br(store, bucket_info, attrs,
+                          nullptr /* no callback */);
+      int ret = br.cancel();
+      if (ret < 0) {
+        if (ret == -EBUSY) {
+          cerr << "There is ongoing resharding, please retry after " <<
+            g_conf->rgw_reshard_bucket_lock_duration <<
+            " seconds " << std::endl;
+        } else {
+          cerr << "Error canceling bucket " << bucket_name <<
+            " resharding: " << cpp_strerror(-ret) << std::endl;
+        }
+        return ret;
       }
-      return ret;
     }
+
     RGWReshard reshard(store);
 
     cls_rgw_reshard_entry entry;
@@ -6336,10 +6350,11 @@ next:
 
     ret = reshard.remove(entry);
     if (ret < 0 && ret != -ENOENT) {
-      cerr << "Error in getting bucket " << bucket_name << ": " << cpp_strerror(-ret) << std::endl;
+      cerr << "Error in updating reshard log with bucket " <<
+        bucket_name << ": " << cpp_strerror(-ret) << std::endl;
       return ret;
     }
-  }
+  } // OPT_RESHARD_CANCEL
 
   if (opt_cmd == OPT_OBJECT_UNLINK) {
     RGWBucketInfo bucket_info;