]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: apply default quota config on account creation 56986/head
authorCasey Bodley <cbodley@redhat.com>
Mon, 22 Apr 2024 14:50:01 +0000 (10:50 -0400)
committerCasey Bodley <cbodley@redhat.com>
Mon, 22 Apr 2024 14:58:46 +0000 (10:58 -0400)
add new default quota config options for accounts analogous to
rgw_user_default_quota_max_objects/size. apply the default bucket quota
config options as-is

Signed-off-by: Casey Bodley <cbodley@redhat.com>
doc/radosgw/admin.rst
doc/radosgw/config-ref.rst
src/common/options/rgw.yaml.in
src/rgw/rgw_account.cc
src/rgw/rgw_quota.cc
src/rgw/rgw_quota.h

index 93ea283a206a7fea77c6bb1549c1896d8b20b2b4..7c7d9d6df148a2bfb0130477ca29d2a469f88054 100644 (file)
@@ -538,8 +538,9 @@ users.** If a default quota is set in the Ceph Object Gateway Config, then that
 quota is set for all subsequently-created users, and that quota is enabled. See
 ``rgw_bucket_default_quota_max_objects``,
 ``rgw_bucket_default_quota_max_size``, ``rgw_user_default_quota_max_objects``,
-and ``rgw_user_default_quota_max_size`` in `Ceph Object Gateway Config
-Reference`_
+``rgw_user_default_quota_max_size``, ``rgw_account_default_quota_max_objects``,
+and ``rgw_account_default_quota_max_size`` in `Ceph Object Gateway Config
+Reference`_.
 
 Quota Cache
 -----------
index 7b009f17996b5fa3dfa824b041fcd11bdb9489eb..9732a2c830c28a11f503157de0667b72a6967b50 100644 (file)
@@ -53,6 +53,8 @@ instances or all radosgw-admin options can be put into the ``[global]`` or the
 .. confval:: rgw_bucket_default_quota_max_size
 .. confval:: rgw_user_default_quota_max_objects
 .. confval:: rgw_user_default_quota_max_size
+.. confval:: rgw_account_default_quota_max_objects
+.. confval:: rgw_account_default_quota_max_size
 .. confval:: rgw_verify_ssl
 .. confval:: rgw_max_chunk_size
 
index ea6a4d64b505ab2622410b0ba37d4f0131bca87e..2e6b5be2af5e036ccf35c5a128b768c0bb8fe81f 100644 (file)
@@ -2300,6 +2300,31 @@ options:
   services:
   - rgw
   with_legacy: true
+- name: rgw_account_default_quota_max_objects
+  type: int
+  level: basic
+  desc: Account quota max objects
+  long_desc: The default quota configuration for total number of objects for a single
+    account. A negative number means 'unlimited'.
+  fmt_desc: Default max number of objects for a account. This includes all
+    objects in all buckets owned by the account. Set on new accounts
+    if no other quota is specified. Has no effect on existing accounts.
+  default: -1
+  services:
+  - rgw
+  with_legacy: true
+- name: rgw_account_default_quota_max_size
+  type: int
+  level: basic
+  desc: Account quota max size
+  long_desc: The default quota configuration for total size of objects for a single
+    account. A negative number means 'unlimited'.
+  fmt_desc: The value for account max size quota in bytes set on new accounts,
+    if no other quota is specified.  Has no effect on existing accounts.
+  default: -1
+  services:
+  - rgw
+  with_legacy: true
 - name: rgw_multipart_min_part_size
   type: size
   level: advanced
index d7e9acd7f5168b8378b34887d6bb51eb59cc460e..af61be8b500e09b24120fd535da06e18c86f4f39 100644 (file)
@@ -22,6 +22,7 @@
 #include "common/utf8.h"
 
 #include "rgw_oidc_provider.h"
+#include "rgw_quota.h"
 #include "rgw_role.h"
 #include "rgw_sal.h"
 
@@ -136,6 +137,10 @@ int create(const DoutPrefixProvider* dpp,
     info.max_buckets = *op_state.max_buckets;
   }
 
+  const ConfigProxy& conf = dpp->get_cct()->_conf;
+  rgw_apply_default_account_quota(info.quota, conf);
+  rgw_apply_default_bucket_quota(info.bucket_quota, conf);
+
   // account id is optional, but must be valid
   if (op_state.account_id.empty()) {
     info.id = generate_id(dpp->get_cct());
index eadd712d664f4176fb2eaa02ed3089417a6a0572..01f5c0cffdf69876bb70a9ae5e4fbb62833e68bc 100644 (file)
@@ -1019,6 +1019,18 @@ void rgw_apply_default_user_quota(RGWQuotaInfo& quota, const ConfigProxy& conf)
   }
 }
 
+void rgw_apply_default_account_quota(RGWQuotaInfo& quota, const ConfigProxy& conf)
+{
+  if (conf->rgw_account_default_quota_max_objects >= 0) {
+    quota.max_objects = conf->rgw_account_default_quota_max_objects;
+    quota.enabled = true;
+  }
+  if (conf->rgw_account_default_quota_max_size >= 0) {
+    quota.max_size = conf->rgw_account_default_quota_max_size;
+    quota.enabled = true;
+  }
+}
+
 void RGWQuotaInfo::dump(Formatter *f) const
 {
   f->dump_bool("enabled", enabled);
index 838fb2439a989ddb35aa3d3c70480b5645dc16ba..7332c522d2b4bf67a8646bd9e78104b57d987bfb 100644 (file)
@@ -20,6 +20,7 @@
 #include "common/lru_map.h"
 
 #include "rgw/rgw_quota_types.h"
+#include "rgw/rgw_user_types.h"
 #include "common/async/yield_context.h"
 #include "rgw_sal_fwd.h"
 
@@ -47,3 +48,4 @@ public:
 // apply default quotas from configuration
 void rgw_apply_default_bucket_quota(RGWQuotaInfo& quota, const ConfigProxy& conf);
 void rgw_apply_default_user_quota(RGWQuotaInfo& quota, const ConfigProxy& conf);
+void rgw_apply_default_account_quota(RGWQuotaInfo& quota, const ConfigProxy& conf);