]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/pubsub: return 404 NotFound instead of NoSuchKey
authorCasey Bodley <cbodley@redhat.com>
Tue, 12 Mar 2024 20:26:44 +0000 (16:26 -0400)
committerCasey Bodley <cbodley@redhat.com>
Fri, 12 Apr 2024 19:34:30 +0000 (15:34 -0400)
repurpose the ERR_NOT_FOUND define which was otherwise unused to
customize the error response for sns apis, which return the NotFound
error code instead of NoSuchKey from s3:

    https://docs.aws.amazon.com/sns/latest/api/API_GetTopicAttributes.html#API_GetTopicAttributes_Errors

this allows boto3 sns clients to catch the NotFoundException as expected

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 2cdddad82ecfc80e03a0b6269eee5981ab5b76f0)

src/rgw/rgw_common.cc
src/rgw/rgw_rest_pubsub.cc

index 6e20c2b145c026eee92497578a96f19e1cbe8332..53244e4436668bec7a8511f3b72ca894b97aa191 100644 (file)
@@ -96,7 +96,7 @@ rgw_http_errors rgw_http_s3_errors({
     { ERR_NO_SUCH_BUCKET, {404, "NoSuchBucket" }},
     { ERR_NO_SUCH_WEBSITE_CONFIGURATION, {404, "NoSuchWebsiteConfiguration" }},
     { ERR_NO_SUCH_UPLOAD, {404, "NoSuchUpload" }},
-    { ERR_NOT_FOUND, {404, "Not Found"}},
+    { ERR_NOT_FOUND, {404, "NotFound"}},
     { ERR_NO_SUCH_LC, {404, "NoSuchLifecycleConfiguration"}},
     { ERR_NO_SUCH_BUCKET_POLICY, {404, "NoSuchBucketPolicy"}},
     { ERR_NO_SUCH_USER, {404, "NoSuchUser"}},
index eeba1a060ae5187ec36a882ab5afae1a34318301..7db88ceddda3f769616479625dabd23521fb097e 100644 (file)
@@ -512,6 +512,10 @@ class RGWPSGetTopicOp : public RGWOp {
     ret = ps.get_topic(this, topic_name, result, y, nullptr);
     if (ret < 0) {
       ldpp_dout(this, 4) << "failed to get topic '" << topic_name << "', ret=" << ret << dendl;
+      if (ret == -ENOENT) {
+        s->err.message = "No such TopicArn";
+        return -ERR_NOT_FOUND; // return NotFound instead of NoSuchKey
+      }
       return ret;
     }
     if (topic_has_endpoint_secret(result) && !verify_transport_security(s->cct, *(s->info.env))) {
@@ -594,6 +598,10 @@ class RGWPSGetTopicAttributesOp : public RGWOp {
     ret = ps.get_topic(this, topic_name, result, y, nullptr);
     if (ret < 0) {
       ldpp_dout(this, 4) << "failed to get topic '" << topic_name << "', ret=" << ret << dendl;
+      if (ret == -ENOENT) {
+        s->err.message = "No such TopicArn";
+        return -ERR_NOT_FOUND; // return NotFound instead of NoSuchKey
+      }
       return ret;
     }
     if (topic_has_endpoint_secret(result) && !verify_transport_security(s->cct, *(s->info.env))) {
@@ -755,6 +763,10 @@ class RGWPSSetTopicAttributesOp : public RGWOp {
     if (ret < 0) {
       ldpp_dout(this, 4) << "failed to get topic '" << topic_name
                          << "', ret=" << ret << dendl;
+      if (ret == -ENOENT) {
+        s->err.message = "No such TopicArn";
+        return -ERR_NOT_FOUND; // return NotFound instead of NoSuchKey
+      }
       return ret;
     }
     topic_owner = result.owner;