From: Casey Bodley Date: Mon, 22 Apr 2024 14:50:01 +0000 (-0400) Subject: rgw: apply default quota config on account creation X-Git-Tag: testing/wip-yuriw-testing-20240424.000125-main~10^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=9ed8263edff7e87907bf24b054e5c7144c194dbe;p=ceph-ci.git rgw: apply default quota config on account creation 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 --- diff --git a/doc/radosgw/admin.rst b/doc/radosgw/admin.rst index 93ea283a206..7c7d9d6df14 100644 --- a/doc/radosgw/admin.rst +++ b/doc/radosgw/admin.rst @@ -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 ----------- diff --git a/doc/radosgw/config-ref.rst b/doc/radosgw/config-ref.rst index 7b009f17996..9732a2c830c 100644 --- a/doc/radosgw/config-ref.rst +++ b/doc/radosgw/config-ref.rst @@ -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 diff --git a/src/common/options/rgw.yaml.in b/src/common/options/rgw.yaml.in index ea6a4d64b50..2e6b5be2af5 100644 --- a/src/common/options/rgw.yaml.in +++ b/src/common/options/rgw.yaml.in @@ -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 diff --git a/src/rgw/rgw_account.cc b/src/rgw/rgw_account.cc index d7e9acd7f51..af61be8b500 100644 --- a/src/rgw/rgw_account.cc +++ b/src/rgw/rgw_account.cc @@ -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()); diff --git a/src/rgw/rgw_quota.cc b/src/rgw/rgw_quota.cc index eadd712d664..01f5c0cffdf 100644 --- a/src/rgw/rgw_quota.cc +++ b/src/rgw/rgw_quota.cc @@ -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); diff --git a/src/rgw/rgw_quota.h b/src/rgw/rgw_quota.h index 838fb2439a9..7332c522d2b 100644 --- a/src/rgw/rgw_quota.h +++ b/src/rgw/rgw_quota.h @@ -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);