Migrate all quota parameters to [quota] section.
Currently we register all parameters about the quota feature to [DEFAULT] section. However it is difficult for operators to identity that some of these parameters like reservation_expire are used in the quota feature, based of names and descriptions of the parameters. This change migrates all quota options to the new [quota] section, so that operators can easily understand which parameters are used in the quota feature. Closes-Bug: #1934025 Change-Id: I83b5750da7083718d39efb56262a49dae0a05f48
This commit is contained in:
parent
b8be5f7f11
commit
76cfc9405e
@ -128,7 +128,6 @@ _global_opt_lists = [
|
||||
manila.network.neutron.neutron_network_plugin.
|
||||
neutron_binding_profile_opts,
|
||||
manila.network.standalone_network_plugin.standalone_network_plugin_opts,
|
||||
manila.quota.quota_opts,
|
||||
manila.scheduler.drivers.base.scheduler_driver_opts,
|
||||
manila.scheduler.host_manager.host_manager_opts,
|
||||
[manila.scheduler.manager.scheduler_driver_opt],
|
||||
@ -203,6 +202,8 @@ _opts = [
|
||||
list(itertools.chain(manila.network.neutron.api.neutron_opts))),
|
||||
(manila.image.glance.GLANCE_GROUP,
|
||||
list(itertools.chain(manila.image.glance.glance_opts))),
|
||||
(manila.quota.QUOTA_GROUP,
|
||||
list(itertools.chain(manila.quota.quota_opts))),
|
||||
]
|
||||
|
||||
_opts.extend(oslo_concurrency.opts.list_opts())
|
||||
|
109
manila/quota.py
109
manila/quota.py
@ -29,54 +29,79 @@ from manila import exception
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
QUOTA_GROUP = 'quota'
|
||||
|
||||
quota_opts = [
|
||||
cfg.IntOpt('quota_shares',
|
||||
cfg.IntOpt('shares',
|
||||
default=50,
|
||||
help='Number of shares allowed per project.'),
|
||||
cfg.IntOpt('quota_snapshots',
|
||||
help='Number of shares allowed per project.',
|
||||
deprecated_group='DEFAULT',
|
||||
deprecated_name='quota_shares'),
|
||||
cfg.IntOpt('snapshots',
|
||||
default=50,
|
||||
help='Number of share snapshots allowed per project.'),
|
||||
cfg.IntOpt('quota_gigabytes',
|
||||
help='Number of share snapshots allowed per project.',
|
||||
deprecated_group='DEFAULT',
|
||||
deprecated_name='quota_snapshots'),
|
||||
cfg.IntOpt('gigabytes',
|
||||
default=1000,
|
||||
help='Number of share gigabytes allowed per project.'),
|
||||
cfg.IntOpt('quota_per_share_gigabytes',
|
||||
help='Number of share gigabytes allowed per project.',
|
||||
deprecated_group='DEFAULT',
|
||||
deprecated_name='quota_gigabytes'),
|
||||
cfg.IntOpt('per_share_gigabytes',
|
||||
default=-1,
|
||||
help='Max size allowed per share, in gigabytes.'),
|
||||
cfg.IntOpt('quota_snapshot_gigabytes',
|
||||
help='Max size allowed per share, in gigabytes.',
|
||||
deprecated_group='DEFAULT',
|
||||
deprecated_name='quota_per_share_gigabytes'),
|
||||
cfg.IntOpt('snapshot_gigabytes',
|
||||
default=1000,
|
||||
help='Number of snapshot gigabytes allowed per project.'),
|
||||
cfg.IntOpt('quota_share_networks',
|
||||
help='Number of snapshot gigabytes allowed per project.',
|
||||
deprecated_group='DEFAULT',
|
||||
deprecated_name='quota_snapshot_gigabytes'),
|
||||
cfg.IntOpt('share_networks',
|
||||
default=10,
|
||||
help='Number of share-networks allowed per project.'),
|
||||
cfg.IntOpt('quota_share_replicas',
|
||||
help='Number of share-networks allowed per project.',
|
||||
deprecated_group='DEFAULT',
|
||||
deprecated_name='quota_share_networks'),
|
||||
cfg.IntOpt('share_replicas',
|
||||
default=100,
|
||||
help='Number of share-replicas allowed per project.'),
|
||||
cfg.IntOpt('quota_replica_gigabytes',
|
||||
help='Number of share-replicas allowed per project.',
|
||||
deprecated_group='DEFAULT',
|
||||
deprecated_name='quota_share_replicas'),
|
||||
cfg.IntOpt('replica_gigabytes',
|
||||
default=1000,
|
||||
help='Number of replica gigabytes allowed per project.'),
|
||||
|
||||
cfg.IntOpt('quota_share_groups',
|
||||
help='Number of replica gigabytes allowed per project.',
|
||||
deprecated_group='DEFAULT',
|
||||
deprecated_name='quota_replica_gigabytes'),
|
||||
cfg.IntOpt('share_groups',
|
||||
default=50,
|
||||
help='Number of share groups allowed.'),
|
||||
cfg.IntOpt('quota_share_group_snapshots',
|
||||
help='Number of share groups allowed.',
|
||||
deprecated_group='DEFAULT',
|
||||
deprecated_name='quota_share_groups'),
|
||||
cfg.IntOpt('share_group_snapshots',
|
||||
default=50,
|
||||
help='Number of share group snapshots allowed.'),
|
||||
|
||||
help='Number of share group snapshots allowed.',
|
||||
deprecated_group='DEFAULT',
|
||||
deprecated_name='quota_share_group_snapshots'),
|
||||
cfg.IntOpt('reservation_expire',
|
||||
default=86400,
|
||||
help='Number of seconds until a reservation expires.'),
|
||||
help='Number of seconds until a reservation expires.',
|
||||
deprecated_group='DEFAULT'),
|
||||
cfg.IntOpt('until_refresh',
|
||||
default=0,
|
||||
help='Count of reservations until usage is refreshed.'),
|
||||
help='Count of reservations until usage is refreshed.',
|
||||
deprecated_group='DEFAULT'),
|
||||
cfg.IntOpt('max_age',
|
||||
default=0,
|
||||
help='Number of seconds between subsequent usage refreshes.'),
|
||||
cfg.StrOpt('quota_driver',
|
||||
help='Number of seconds between subsequent usage refreshes.',
|
||||
deprecated_group='DEFAULT'),
|
||||
cfg.StrOpt('driver',
|
||||
default='manila.quota.DbQuotaDriver',
|
||||
help='Default driver to use for quota checks.'), ]
|
||||
help='Default driver to use for quota checks.',
|
||||
deprecated_group='DEFAULT',
|
||||
deprecated_name='quota_driver'), ]
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.register_opts(quota_opts)
|
||||
CONF.register_opts(quota_opts, QUOTA_GROUP)
|
||||
|
||||
|
||||
class DbQuotaDriver(object):
|
||||
@ -473,7 +498,7 @@ class DbQuotaDriver(object):
|
||||
|
||||
# Set up the reservation expiration
|
||||
if expire is None:
|
||||
expire = CONF.reservation_expire
|
||||
expire = CONF.quota.reservation_expire
|
||||
if isinstance(expire, six.integer_types):
|
||||
expire = datetime.timedelta(seconds=expire)
|
||||
if isinstance(expire, datetime.timedelta):
|
||||
@ -511,7 +536,7 @@ class DbQuotaDriver(object):
|
||||
# have to do the work there.
|
||||
return db.quota_reserve(
|
||||
context, resources, quotas, user_quotas, share_type_quotas,
|
||||
deltas, expire, CONF.until_refresh, CONF.max_age,
|
||||
deltas, expire, CONF.quota.until_refresh, CONF.quota.max_age,
|
||||
project_id=project_id, user_id=user_id,
|
||||
share_type_id=share_type_id, overquota_allowed=overquota_allowed)
|
||||
|
||||
@ -669,7 +694,7 @@ class BaseResource(object):
|
||||
def default(self):
|
||||
"""Return the default value of the quota."""
|
||||
|
||||
return CONF[self.flag] if self.flag else -1
|
||||
return CONF.quota[self.flag] if self.flag else -1
|
||||
|
||||
|
||||
class ReservableResource(BaseResource):
|
||||
@ -768,7 +793,7 @@ class QuotaEngine(object):
|
||||
if self.__driver:
|
||||
return self.__driver
|
||||
if not self._driver_cls:
|
||||
self._driver_cls = CONF.quota_driver
|
||||
self._driver_cls = CONF.quota.driver
|
||||
if isinstance(self._driver_cls, six.string_types):
|
||||
self._driver_cls = importutils.import_object(self._driver_cls)
|
||||
self.__driver = self._driver_cls
|
||||
@ -1132,23 +1157,23 @@ QUOTAS = QuotaEngine()
|
||||
|
||||
|
||||
resources = [
|
||||
ReservableResource('shares', '_sync_shares', 'quota_shares'),
|
||||
ReservableResource('snapshots', '_sync_snapshots', 'quota_snapshots'),
|
||||
ReservableResource('gigabytes', '_sync_gigabytes', 'quota_gigabytes'),
|
||||
ReservableResource('shares', '_sync_shares', 'shares'),
|
||||
ReservableResource('snapshots', '_sync_snapshots', 'snapshots'),
|
||||
ReservableResource('gigabytes', '_sync_gigabytes', 'gigabytes'),
|
||||
ReservableResource('per_share_gigabytes', None,
|
||||
'quota_per_share_gigabytes'),
|
||||
'per_share_gigabytes'),
|
||||
ReservableResource('snapshot_gigabytes', '_sync_snapshot_gigabytes',
|
||||
'quota_snapshot_gigabytes'),
|
||||
'snapshot_gigabytes'),
|
||||
ReservableResource('share_networks', '_sync_share_networks',
|
||||
'quota_share_networks'),
|
||||
'share_networks'),
|
||||
ReservableResource('share_groups', '_sync_share_groups',
|
||||
'quota_share_groups'),
|
||||
'share_groups'),
|
||||
ReservableResource('share_group_snapshots', '_sync_share_group_snapshots',
|
||||
'quota_share_group_snapshots'),
|
||||
'share_group_snapshots'),
|
||||
ReservableResource('share_replicas', '_sync_share_replicas',
|
||||
'quota_share_replicas'),
|
||||
'share_replicas'),
|
||||
ReservableResource('replica_gigabytes', '_sync_replica_gigabytes',
|
||||
'quota_replica_gigabytes'),
|
||||
'replica_gigabytes'),
|
||||
]
|
||||
|
||||
|
||||
|
@ -87,7 +87,7 @@ class QuotaSetsControllerTest(test.TestCase):
|
||||
}
|
||||
}
|
||||
for k, v in quotas.items():
|
||||
CONF.set_default('quota_' + k, v)
|
||||
CONF.set_default(k, v, 'quota')
|
||||
|
||||
if req.api_version_request >= api_version.APIVersionRequest("2.40"):
|
||||
expected['quota_class_set']['share_groups'] = 50
|
||||
@ -129,7 +129,7 @@ class QuotaSetsControllerTest(test.TestCase):
|
||||
req = fakes.HTTPRequest.blank(
|
||||
'/fooproject/%squota-class-sets' % url,
|
||||
version=version, use_admin_context=True)
|
||||
CONF.set_default('quota_shares', 789)
|
||||
CONF.set_default('shares', 789, 'quota')
|
||||
body = {
|
||||
'quota_class_set': {
|
||||
'class_name': self.class_name,
|
||||
|
@ -80,7 +80,7 @@ class QuotaSetsControllerTest(test.TestCase):
|
||||
def test_defaults(self, quotas):
|
||||
req = _get_request(True, False)
|
||||
for k, v in quotas.items():
|
||||
CONF.set_default('quota_' + k, v)
|
||||
CONF.set_default(k, v, 'quota')
|
||||
expected = {
|
||||
'quota_set': {
|
||||
'id': self.project_id,
|
||||
@ -174,7 +174,7 @@ class QuotaSetsControllerTest(test.TestCase):
|
||||
},
|
||||
}}
|
||||
for k, v in quotas.items():
|
||||
CONF.set_default('quota_' + k, v)
|
||||
CONF.set_default(k, v, 'quota')
|
||||
|
||||
result = self.controller.detail(req, self.project_id)
|
||||
|
||||
@ -206,7 +206,7 @@ class QuotaSetsControllerTest(test.TestCase):
|
||||
}
|
||||
}
|
||||
for k, v in quotas.items():
|
||||
CONF.set_default('quota_' + k, v)
|
||||
CONF.set_default(k, v, 'quota')
|
||||
|
||||
result = self.controller.show(req, self.project_id)
|
||||
|
||||
@ -355,7 +355,7 @@ class QuotaSetsControllerTest(test.TestCase):
|
||||
}
|
||||
}
|
||||
for k, v in quotas.items():
|
||||
CONF.set_default('quota_' + k, v)
|
||||
CONF.set_default(k, v, 'quota')
|
||||
|
||||
result = self.controller.detail(request, self.project_id)
|
||||
|
||||
@ -388,7 +388,7 @@ class QuotaSetsControllerTest(test.TestCase):
|
||||
}
|
||||
}
|
||||
for k, v in quotas.items():
|
||||
CONF.set_default('quota_' + k, v)
|
||||
CONF.set_default(k, v, 'quota')
|
||||
|
||||
result = self.controller.show(request, self.project_id)
|
||||
|
||||
@ -416,7 +416,7 @@ class QuotaSetsControllerTest(test.TestCase):
|
||||
quota_sets.db, 'share_type_get_by_name_or_id',
|
||||
mock.Mock(
|
||||
return_value={'id': 'fake_st_id', 'name': 'fake_st_name'}))
|
||||
CONF.set_default('quota_shares', 789)
|
||||
CONF.set_default('shares', 789, 'quota')
|
||||
body = {'quota_set': {'tenant_id': self.project_id, 'shares': 788}}
|
||||
expected = {
|
||||
'quota_set': {
|
||||
@ -479,7 +479,7 @@ class QuotaSetsControllerTest(test.TestCase):
|
||||
return_value={'id': 'fake_st_id', 'name': 'fake_st_name'}))
|
||||
req = self._get_share_type_request_object(microversion)
|
||||
|
||||
CONF.set_default('quota_shares', 789)
|
||||
CONF.set_default('shares', 789, 'quota')
|
||||
body = {'quota_set': {'tenant_id': self.project_id, 'shares': 788}}
|
||||
expected = {
|
||||
'quota_set': {
|
||||
@ -558,7 +558,7 @@ class QuotaSetsControllerTest(test.TestCase):
|
||||
|
||||
def test_user_quota_can_not_be_bigger_than_tenant_quota(self):
|
||||
value = 777
|
||||
CONF.set_default('quota_shares', value)
|
||||
CONF.set_default('shares', value, 'quota')
|
||||
body = {
|
||||
'quota_set': {
|
||||
'tenant_id': self.project_id,
|
||||
|
@ -911,7 +911,7 @@ class ShareAPITestCase(test.TestCase):
|
||||
expected_exception):
|
||||
share, share_data = self._setup_create_mocks()
|
||||
|
||||
quota.CONF.set_default("quota_per_share_gigabytes", 5)
|
||||
quota.CONF.set_default("per_share_gigabytes", 5, 'quota')
|
||||
share_data['size'] = 20
|
||||
|
||||
usages = {'per_share_gigabytes': {'reserved': 0, 'in_use': 0}}
|
||||
@ -2867,7 +2867,7 @@ class ShareAPITestCase(test.TestCase):
|
||||
self.api.extend, self.context, share, new_size)
|
||||
|
||||
def test_extend_share_over_per_share_quota(self):
|
||||
quota.CONF.set_default("quota_per_share_gigabytes", 5)
|
||||
quota.CONF.set_default("per_share_gigabytes", 5, 'quota')
|
||||
share = db_utils.create_share(status=constants.STATUS_AVAILABLE,
|
||||
size=4)
|
||||
new_size = 6
|
||||
|
@ -361,7 +361,7 @@ class DbQuotaDriverTestCase(test.TestCase):
|
||||
self.assertEqual(quota.db.quota_reserve.return_value, result)
|
||||
quota.db.quota_reserve.assert_called_once_with(
|
||||
self.ctxt, self.resources, quotas, user_quotas, st_quotas,
|
||||
deltas, mock.ANY, CONF.until_refresh, CONF.max_age,
|
||||
deltas, mock.ANY, CONF.quota.until_refresh, CONF.quota.max_age,
|
||||
**expected_kwargs)
|
||||
self.assertEqual(
|
||||
3 if kwargs.get('share_type_id') else 2,
|
||||
|
23
releasenotes/notes/add-quotas-section-0e1e638a8f14d26e.yaml
Normal file
23
releasenotes/notes/add-quotas-section-0e1e638a8f14d26e.yaml
Normal file
@ -0,0 +1,23 @@
|
||||
---
|
||||
deprecations:
|
||||
- |
|
||||
Configuration options to define default quota and behavior of the quota
|
||||
feature must now be configured in the new ``[quota]`` section rather than
|
||||
the ``[DEFAULT]`` section. The existing options in the ``[DEFAULT]``
|
||||
section have been deprecated and will be removed in a future release.
|
||||
Options that have changed in this releases are:
|
||||
|
||||
- ``[quota]/shares`` - previously ``[DEFAULT]/shares_quota``
|
||||
- ``[quota]/snapshots`` - previously ``[DEFAULT]/snapshots_quota``
|
||||
- ``[quota]/gigabytes`` - previously ``[DEFAULT]/quota_gigabytes``
|
||||
- ``[quota]/per_share_gigabytes`` - previously ``[DEFAULT]/quota_per_share_gigabytes``
|
||||
- ``[quota]/snapshot_gigabytes`` - previously ``[DEFAULT]/quota_snapshot_gigabytes``
|
||||
- ``[quota]/share_networks`` - previously ``[DEFAULT]/quota_share_networks``
|
||||
- ``[quota]/share_groups`` - previously ``[DEFAULT]/quota_share_groups``
|
||||
- ``[quota]/share_group_snapshots`` - previously ``[DEFAULT]/quota_share_group_snapshots``
|
||||
- ``[quota]/share_replicas`` - previously ``[DEFAULT]/quota_share_replicas``
|
||||
- ``[quota]/replica_gigabytes`` - previously ``[DEFAULT]/quota_replica_gigabytes``
|
||||
- ``[quota]/until_refresh`` - previously ``[DEFAULT]/until_refresh``
|
||||
- ``[quota]/reservation_expire`` previously ``[DEFAULT]/reservation_expire``
|
||||
- ``[quota]/driver`` - previously ``[DEFAULT]/quota_driver``
|
||||
- ``[quota]/max_age`` - previously ``[DEFAULT]/max_age``
|
Loading…
Reference in New Issue
Block a user