From: Yehuda Sadeh Date: Wed, 20 Jan 2016 19:52:48 +0000 (-0800) Subject: rgw: fix create bucket error handling X-Git-Tag: v10.0.4~152^2^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=eeae702d6e83f506bfc11be9a3d8b8a90210479f;p=ceph.git rgw: fix create bucket error handling Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 747c224d04d..34a5ff3e7ca 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -1833,7 +1833,8 @@ void RGWCreateBucket::execute() ldout(s->cct, 0) << "WARNING: failed to unlink bucket: ret=" << ret << dendl; } } else if (ret == -EEXIST || (ret == 0 && existed)) { - ret = -ERR_BUCKET_EXISTS; + ret = 0; + exist_ret = -ERR_BUCKET_EXISTS; } } diff --git a/src/rgw/rgw_op.h b/src/rgw/rgw_op.h index 5598c4b4956..5395817bb97 100644 --- a/src/rgw/rgw_op.h +++ b/src/rgw/rgw_op.h @@ -530,8 +530,10 @@ protected: bufferlist in_data; + int exist_ret; + public: - RGWCreateBucket() : has_cors(false) {} + RGWCreateBucket() : has_cors(false), exist_ret(0) {} int verify_permission(); void pre_exec(); diff --git a/src/rgw/rgw_rest_swift.cc b/src/rgw/rgw_rest_swift.cc index b170272bdea..a0bcc04fb4b 100644 --- a/src/rgw/rgw_rest_swift.cc +++ b/src/rgw/rgw_rest_swift.cc @@ -467,10 +467,11 @@ int RGWCreateBucket_ObjStore_SWIFT::get_params() void RGWCreateBucket_ObjStore_SWIFT::send_response() { - if (!ret) - ret = STATUS_CREATED; - else if (ret == -ERR_BUCKET_EXISTS) + if (exist_ret == -ERR_BUCKET_EXISTS) { ret = STATUS_ACCEPTED; + } else if (!ret) { + ret = STATUS_CREATED; + } set_req_state_err(s, ret); dump_errno(s); /* Propose ending HTTP header with 0 Content-Length header. */