}
if (opt_cmd == OPT_RESHARD_CANCEL) {
- RGWReshard reshard(store);
-
if (bucket_name.empty()) {
cerr << "ERROR: bucket not specified" << std::endl;
return EINVAL;
}
- cls_rgw_reshard_entry entry;
- //entry.tenant = tenant;
- entry.bucket_name = bucket_name;
- //entry.bucket_id = bucket_id;
- int ret = reshard.get(entry);
+
+ rgw_bucket bucket;
+ RGWBucketInfo bucket_info;
+ map<string, bufferlist> attrs;
+ ret = init_bucket(tenant, bucket_name, bucket_id, bucket_info, bucket, &attrs);
if (ret < 0) {
- cerr << "Error in getting bucket " << bucket_name << ": " << cpp_strerror(-ret) << std::endl;
- return ret;
+ cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl;
+ return -ret;
}
- /* TBD stop running resharding */
-
- ret =reshard.remove(entry);
+ RGWBucketReshard br(store, bucket_info, attrs);
+ int ret = br.cancel();
if (ret < 0) {
- cerr << "Error removing bucket " << bucket_name << " for resharding queue: " << cpp_strerror(-ret) <<
+ cerr << "Error canceling bucket " << bucket_name << " resharding: " << cpp_strerror(-ret) <<
std::endl;
return ret;
}
+
+ RGWReshard reshard(store);
+
+ cls_rgw_reshard_entry entry;
+ //entry.tenant = tenant;
+ entry.bucket_name = bucket_name;
+ //entry.bucket_id = bucket_id;
+
+ ret = reshard.get(entry);
+ if (ret < 0 && ret != -ENOENT) {
+ cerr << "Error in getting bucket " << bucket_name << ": " << cpp_strerror(-ret) << std::endl;
+ return ret;
+ } else if (ret != -ENOENT) {
+ ret = reshard.remove(entry);
+ if (ret < 0) {
+ cerr << "Error removing bucket " << bucket_name << " from resharding queue: " << cpp_strerror(-ret) <<
+ std::endl;
+ return ret;
+ }
+ }
}
if (opt_cmd == OPT_OBJECT_UNLINK) {
return ::create_new_bucket_instance(store, new_num_shards, bucket_info, bucket_attrs, new_bucket_info);
}
+int RGWBucketReshard::cancel()
+{
+ int ret = lock_bucket();
+ if (ret < 0) {
+ return ret;
+ }
+
+ ret = clear_resharding();
+
+ unlock_bucket();
+ return 0;
+}
+
class BucketInfoReshardUpdate
{
RGWRados *store;