From: mengxiangrui Date: Tue, 6 Jul 2021 11:58:55 +0000 (+0800) Subject: rgw: fail as expected when set/delete-bucket-website attempted on a non-existent... X-Git-Tag: v16.2.6~83^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d3343e48b5ee45538ee6d32814de5988d4ce1cd2;p=ceph.git rgw: fail as expected when set/delete-bucket-website attempted on a non-existent bucket, rgw should return HTTP 404 and NoSuchBucket. Fixes: https://tracker.ceph.com/issues/51536 Signed-off-by: xiangrui meng (cherry picked from commit c623aa45d35b269c6701a57e44ac05bb29a79dc8) --- diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 7f0f17124aeb..2a8a88946070 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -2647,6 +2647,11 @@ void RGWSetBucketWebsite::execute(optional_yield y) if (op_ret < 0) return; + if (!s->bucket_exists) { + op_ret = -ERR_NO_SUCH_BUCKET; + return; + } + op_ret = store->forward_request_to_master(this, s->user.get(), nullptr, in_data, nullptr, s->info, y); if (op_ret < 0) { ldpp_dout(this, 0) << " forward_request_to_master returned ret=" << op_ret << dendl; @@ -2679,6 +2684,11 @@ void RGWDeleteBucketWebsite::pre_exec() void RGWDeleteBucketWebsite::execute(optional_yield y) { + if (!s->bucket_exists) { + op_ret = -ERR_NO_SUCH_BUCKET; + return; + } + bufferlist in_data; op_ret = store->forward_request_to_master(this, s->user.get(), nullptr, in_data, nullptr, s->info, y);