Skip to content

Commit 9ed8263

Browse files
committed
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 <[email protected]>
1 parent b967771 commit 9ed8263

File tree

6 files changed

+49
-2
lines changed

6 files changed

+49
-2
lines changed

doc/radosgw/admin.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,8 +538,9 @@ users.** If a default quota is set in the Ceph Object Gateway Config, then that
538538
quota is set for all subsequently-created users, and that quota is enabled. See
539539
``rgw_bucket_default_quota_max_objects``,
540540
``rgw_bucket_default_quota_max_size``, ``rgw_user_default_quota_max_objects``,
541-
and ``rgw_user_default_quota_max_size`` in `Ceph Object Gateway Config
542-
Reference`_
541+
``rgw_user_default_quota_max_size``, ``rgw_account_default_quota_max_objects``,
542+
and ``rgw_account_default_quota_max_size`` in `Ceph Object Gateway Config
543+
Reference`_.
543544

544545
Quota Cache
545546
-----------

doc/radosgw/config-ref.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ instances or all radosgw-admin options can be put into the ``[global]`` or the
5353
.. confval:: rgw_bucket_default_quota_max_size
5454
.. confval:: rgw_user_default_quota_max_objects
5555
.. confval:: rgw_user_default_quota_max_size
56+
.. confval:: rgw_account_default_quota_max_objects
57+
.. confval:: rgw_account_default_quota_max_size
5658
.. confval:: rgw_verify_ssl
5759
.. confval:: rgw_max_chunk_size
5860

src/common/options/rgw.yaml.in

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2300,6 +2300,31 @@ options:
23002300
services:
23012301
- rgw
23022302
with_legacy: true
2303+
- name: rgw_account_default_quota_max_objects
2304+
type: int
2305+
level: basic
2306+
desc: Account quota max objects
2307+
long_desc: The default quota configuration for total number of objects for a single
2308+
account. A negative number means 'unlimited'.
2309+
fmt_desc: Default max number of objects for a account. This includes all
2310+
objects in all buckets owned by the account. Set on new accounts
2311+
if no other quota is specified. Has no effect on existing accounts.
2312+
default: -1
2313+
services:
2314+
- rgw
2315+
with_legacy: true
2316+
- name: rgw_account_default_quota_max_size
2317+
type: int
2318+
level: basic
2319+
desc: Account quota max size
2320+
long_desc: The default quota configuration for total size of objects for a single
2321+
account. A negative number means 'unlimited'.
2322+
fmt_desc: The value for account max size quota in bytes set on new accounts,
2323+
if no other quota is specified. Has no effect on existing accounts.
2324+
default: -1
2325+
services:
2326+
- rgw
2327+
with_legacy: true
23032328
- name: rgw_multipart_min_part_size
23042329
type: size
23052330
level: advanced

src/rgw/rgw_account.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "common/utf8.h"
2323

2424
#include "rgw_oidc_provider.h"
25+
#include "rgw_quota.h"
2526
#include "rgw_role.h"
2627
#include "rgw_sal.h"
2728

@@ -136,6 +137,10 @@ int create(const DoutPrefixProvider* dpp,
136137
info.max_buckets = *op_state.max_buckets;
137138
}
138139

140+
const ConfigProxy& conf = dpp->get_cct()->_conf;
141+
rgw_apply_default_account_quota(info.quota, conf);
142+
rgw_apply_default_bucket_quota(info.bucket_quota, conf);
143+
139144
// account id is optional, but must be valid
140145
if (op_state.account_id.empty()) {
141146
info.id = generate_id(dpp->get_cct());

src/rgw/rgw_quota.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,6 +1019,18 @@ void rgw_apply_default_user_quota(RGWQuotaInfo& quota, const ConfigProxy& conf)
10191019
}
10201020
}
10211021

1022+
void rgw_apply_default_account_quota(RGWQuotaInfo& quota, const ConfigProxy& conf)
1023+
{
1024+
if (conf->rgw_account_default_quota_max_objects >= 0) {
1025+
quota.max_objects = conf->rgw_account_default_quota_max_objects;
1026+
quota.enabled = true;
1027+
}
1028+
if (conf->rgw_account_default_quota_max_size >= 0) {
1029+
quota.max_size = conf->rgw_account_default_quota_max_size;
1030+
quota.enabled = true;
1031+
}
1032+
}
1033+
10221034
void RGWQuotaInfo::dump(Formatter *f) const
10231035
{
10241036
f->dump_bool("enabled", enabled);

src/rgw/rgw_quota.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "common/lru_map.h"
2121

2222
#include "rgw/rgw_quota_types.h"
23+
#include "rgw/rgw_user_types.h"
2324
#include "common/async/yield_context.h"
2425
#include "rgw_sal_fwd.h"
2526

@@ -47,3 +48,4 @@ class RGWQuotaHandler {
4748
// apply default quotas from configuration
4849
void rgw_apply_default_bucket_quota(RGWQuotaInfo& quota, const ConfigProxy& conf);
4950
void rgw_apply_default_user_quota(RGWQuotaInfo& quota, const ConfigProxy& conf);
51+
void rgw_apply_default_account_quota(RGWQuotaInfo& quota, const ConfigProxy& conf);

0 commit comments

Comments
 (0)