@@ -216,36 +216,24 @@ class RGWOp_Bucket_Remove : public RGWRESTOp {
216216
217217void RGWOp_Bucket_Remove::execute (optional_yield y)
218218{
219- std::string bucket_name;
220- bool delete_children;
221- std::unique_ptr<rgw::sal::Bucket> bucket;
219+ std::string bucket_name, tenant;
220+ bool delete_children, bypass_gc;
222221
223222 RESTArgs::get_string (s, " bucket" , bucket_name, &bucket_name);
223+ RESTArgs::get_string (s, " tenant" , tenant, &tenant);
224224 RESTArgs::get_bool (s, " purge-objects" , false , &delete_children);
225+ RESTArgs::get_bool (s, " bypass-gc" , false , &bypass_gc);
225226
226- op_ret = rgw_forward_request_to_master (this , *s->penv .site , s->user ->get_id (),
227- nullptr , nullptr , s->info , y);
228- if (op_ret < 0 ) {
229- ldpp_dout (this , 0 ) << " forward_request_to_master returned ret=" << op_ret << dendl;
230- if (op_ret == -ENOENT) {
231- /* adjust error, we want to return with NoSuchBucket and not
232- * NoSuchKey */
233- op_ret = -ERR_NO_SUCH_BUCKET;
234- }
235- return ;
236- }
227+ RGWBucketAdminOpState op_state;
228+ op_state.set_bucket_name (bucket_name);
229+ op_state.set_tenant (tenant);
230+ op_state.set_delete_children (delete_children);
237231
238- op_ret = driver->load_bucket (s, rgw_bucket (" " , bucket_name),
239- &bucket, y);
240- if (op_ret < 0 ) {
241- ldpp_dout (this , 0 ) << " get_bucket returned ret=" << op_ret << dendl;
242- if (op_ret == -ENOENT) {
243- op_ret = -ERR_NO_SUCH_BUCKET;
244- }
245- return ;
246- }
232+ // Check if the request is being forwarded by looking for the "rgwx-zonegroup" argument
233+ // As this is an admin endpoint, checking by system_request is not sufficient
234+ const bool is_forwarded = s->info .args .exists (RGW_SYS_PARAM_PREFIX " zonegroup" );
247235
248- op_ret = bucket-> remove (s, delete_children, s-> yield );
236+ op_ret = RGWBucketAdminOp::remove_bucket (driver, *s-> penv . site , op_state, y, s, bypass_gc, true , is_forwarded );
249237}
250238
251239class RGWOp_Set_Bucket_Quota : public RGWRESTOp {
0 commit comments