From 263a10615c34d925b19b5ff9760df606ce38877e Mon Sep 17 00:00:00 2001 From: Raja Sharma Date: Sun, 17 Nov 2024 14:28:24 +0530 Subject: [PATCH] rgw:Wrong x-rgw-quota-bucket-objects header when bucket quota is disabled This commit introduces to get quota settings if bucket quota is enabled Fixes: https://tracker.ceph.com/issues/68211 Signed-off-by: Raja Sharma --- src/rgw/rgw_rest_s3.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index a245fca9945..68223405cf4 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -2399,11 +2399,17 @@ static void dump_bucket_metadata(req_state *s, rgw::sal::Bucket* bucket, if (s->auth.identity->is_owner_of(bucket->get_owner())) { const auto& user_info = s->user->get_info(); const auto& bucket_quota = s->bucket->get_info().quota; // bucket quota - dump_header(s, "X-RGW-Quota-User-Size", static_cast(user_info.quota.user_quota.max_size)); - dump_header(s, "X-RGW-Quota-User-Objects", static_cast(user_info.quota.user_quota.max_objects)); dump_header(s, "X-RGW-Quota-Max-Buckets", static_cast(user_info.max_buckets)); - dump_header(s, "X-RGW-Quota-Bucket-Size", static_cast(bucket_quota.max_size)); - dump_header(s, "X-RGW-Quota-Bucket-Objects", static_cast(bucket_quota.max_objects)); + + if (user_info.quota.user_quota.enabled){ + dump_header(s, "X-RGW-Quota-User-Size", static_cast(user_info.quota.user_quota.max_size)); + dump_header(s, "X-RGW-Quota-User-Objects", static_cast(user_info.quota.user_quota.max_objects)); + } + + if (bucket_quota.enabled){ + dump_header(s, "X-RGW-Quota-Bucket-Size", static_cast(bucket_quota.max_size)); + dump_header(s, "X-RGW-Quota-Bucket-Objects", static_cast(bucket_quota.max_objects)); + } } } -- 2.39.5