From 51ab8abf7586ac7a5014396b8e64f657ea842bb9 Mon Sep 17 00:00:00 2001 From: Zhao Chao Date: Tue, 4 Jul 2017 15:44:41 +0800 Subject: [PATCH] rgw: add a new error code for non-existed subuser. When modify or delete non-existed subuser, a new error code 'NoSuchSubUser' is more specific than 'InvalidArgument'. Signed-off-by: Zhao Chao --- src/rgw/rgw_common.cc | 1 + src/rgw/rgw_common.h | 1 + src/rgw/rgw_user.cc | 6 +++--- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/rgw/rgw_common.cc b/src/rgw/rgw_common.cc index d4e494073ca..73c650c5ff6 100644 --- a/src/rgw/rgw_common.cc +++ b/src/rgw/rgw_common.cc @@ -89,6 +89,7 @@ rgw_http_errors rgw_http_s3_errors({ { ERR_NOT_FOUND, {404, "Not Found"}}, { ERR_NO_SUCH_LC, {404, "NoSuchLifecycleConfiguration"}}, { ERR_NO_SUCH_BUCKET_POLICY, {404, "NoSuchBucketPolicy"}}, + { ERR_NO_SUCH_SUBUSER, {404, "NoSuchSubUser"}}, { ERR_METHOD_NOT_ALLOWED, {405, "MethodNotAllowed" }}, { ETIMEDOUT, {408, "RequestTimeout" }}, { EEXIST, {409, "BucketAlreadyExists" }}, diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index bf05d13a12f..c71aa472609 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -198,6 +198,7 @@ using ceph::crypto::MD5; #define ERR_NO_SUCH_WEBSITE_CONFIGURATION 2039 #define ERR_AMZ_CONTENT_SHA256_MISMATCH 2040 #define ERR_NO_SUCH_LC 2041 +#define ERR_NO_SUCH_SUBUSER 2043 #define ERR_USER_SUSPENDED 2100 #define ERR_INTERNAL_ERROR 2200 #define ERR_NOT_IMPLEMENTED 2201 diff --git a/src/rgw/rgw_user.cc b/src/rgw/rgw_user.cc index a73ff047f58..4eb803e5cf4 100644 --- a/src/rgw/rgw_user.cc +++ b/src/rgw/rgw_user.cc @@ -1419,11 +1419,11 @@ int RGWSubUserPool::execute_remove(RGWUserAdminOpState& op_state, siter = subuser_map->find(subuser_str); if (siter == subuser_map->end()){ set_err_msg(err_msg, "subuser not found: " + subuser_str); - return -EINVAL; + return -ERR_NO_SUCH_SUBUSER; } if (!op_state.has_existing_subuser()) { set_err_msg(err_msg, "subuser not found: " + subuser_str); - return -EINVAL; + return -ERR_NO_SUCH_SUBUSER; } // always purge all associate keys @@ -1479,7 +1479,7 @@ int RGWSubUserPool::execute_modify(RGWUserAdminOpState& op_state, std::string *e if (!op_state.has_existing_subuser()) { set_err_msg(err_msg, "subuser does not exist"); - return -EINVAL; + return -ERR_NO_SUCH_SUBUSER; } subuser_pair.first = subuser_str; -- 2.39.5