]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw: add containers quota to swift rest headers
authorPhilip de Nier <philipn@rd.bbc.co.uk>
Wed, 22 Feb 2023 13:05:17 +0000 (13:05 +0000)
committerPhilip de Nier <philipn@rd.bbc.co.uk>
Wed, 22 Feb 2023 13:05:17 +0000 (13:05 +0000)
This commit adds "X-Account-Meta-Quota-Containers" to
the Swift API response headers. The value is the Ceph max buckets
user quota.

Users can then get access to the bucket / container quota via the
Swift API and commandline client, and the openstack commandline client.

Signed-off-by: Philip de Nier <philipn@rd.bbc.co.uk>
src/rgw/rgw_rest_swift.cc

index a3ab698ac191ffc6433d3e80cabd31ea55aa6602..76f7da3616d3efb2dd02fa98871f57afcd524550 100644 (file)
@@ -91,6 +91,7 @@ static void dump_account_metadata(req_state * const s,
                                   const std::map<std::string, RGWUsageStats> &policies_stats,
                                   /* const */map<string, bufferlist>& attrs,
                                   const RGWQuotaInfo& quota,
+                                  int32_t max_buckets,
                                   const RGWAccessControlPolicy_SWIFTAcct &policy)
 {
   /* Adding X-Timestamp to keep align with Swift API */
@@ -141,6 +142,12 @@ static void dump_account_metadata(req_state * const s,
     }
   }
 
+  /* Limit on the number of containers in a given account is a RadosGW's
+   * extension. Swift's account quota WSGI filter doesn't support it. */
+  if (max_buckets >= 0) {
+    dump_header(s, "X-Account-Meta-Quota-Containers", max_buckets);
+  }
+
   /* Dump user-defined metadata items and generic attrs. */
   const size_t PREFIX_LEN = sizeof(RGW_ATTR_META_PREFIX) - 1;
   map<string, bufferlist>::iterator iter;
@@ -180,6 +187,7 @@ void RGWListBuckets_ObjStore_SWIFT::send_response_begin(bool has_buckets)
             policies_stats,
             s->user->get_attrs(),
             s->user->get_info().quota.user_quota,
+            s->user->get_max_buckets(),
             static_cast<RGWAccessControlPolicy_SWIFTAcct&>(*s->user_acl));
     dump_errno(s);
     dump_header(s, "Accept-Ranges", "bytes");
@@ -286,6 +294,7 @@ void RGWListBuckets_ObjStore_SWIFT::send_response_end()
             policies_stats,
             s->user->get_attrs(),
             s->user->get_info().quota.user_quota,
+            s->user->get_max_buckets(),
             static_cast<RGWAccessControlPolicy_SWIFTAcct&>(*s->user_acl));
     dump_errno(s);
     end_header(s, nullptr, nullptr, s->formatter->get_len(), true);
@@ -561,6 +570,7 @@ void RGWStatAccount_ObjStore_SWIFT::send_response()
             policies_stats,
             attrs,
             s->user->get_info().quota.user_quota,
+            s->user->get_max_buckets(),
             static_cast<RGWAccessControlPolicy_SWIFTAcct&>(*s->user_acl));
   }