Remove consistencygroups quota entries

Consistency Groups in Cinder were redirected internally to "groups", but
there is still a lot of unused code lingering around the
project.

This patch focuses on removing the quota related bits which are easy to
remove, and defers the more complex removal of the rest of the code to a
later time.

Change-Id: I1d8aba119e85407b54b9bea03a0a6d632707be07
This commit is contained in:
Gorka Eguileor 2021-11-10 12:12:34 +01:00
parent 1a9e911ad4
commit 2b88148c6c
5 changed files with 57 additions and 48 deletions

View File

@ -44,7 +44,6 @@ CONF = cfg.CONF
CONF.import_opt('quota_volumes', 'cinder.quota')
CONF.import_opt('quota_snapshots', 'cinder.quota')
CONF.import_opt('quota_gigabytes', 'cinder.quota')
CONF.import_opt('quota_consistencygroups', 'cinder.quota')
CLASS_NAME = 'default'
CREATED_AT = datetime.datetime.now() # noqa
@ -994,13 +993,6 @@ def upgrade():
'hard_limit': CONF.quota_gigabytes,
'deleted': False,
},
{
'created_at': CREATED_AT,
'class_name': CLASS_NAME,
'resource': 'consistencygroups',
'hard_limit': CONF.quota_consistencygroups,
'deleted': False,
},
{
'created_at': CREATED_AT,
'class_name': CLASS_NAME,

View File

@ -0,0 +1,45 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""Remove quota consistencygroups
Revision ID: b7b88f50aab5
Revises: 9ab1b092a404
Create Date: 2021-11-10 11:54:50.123389
"""
from alembic import op
from sqlalchemy import orm
from cinder.db.sqlalchemy import models
# revision identifiers, used by Alembic.
revision = 'b7b88f50aab5'
down_revision = '9ab1b092a404'
branch_labels = None
depends_on = None
def upgrade():
bind = op.get_bind()
session = orm.Session(bind=bind)
with session.begin():
for model in (models.QuotaClass,
models.Quota,
models.QuotaUsage,
models.Reservation):
session.query(model)\
.filter_by(deleted=False, resource='consistencygroups')\
.update(model.delete_values())

View File

@ -656,17 +656,6 @@ def _sync_gigabytes(
return {key: vol_gigs + snap_gigs}
def _sync_consistencygroups(
context,
project_id,
volume_type_id=None,
volume_type_name=None,
):
_, groups = _consistencygroup_data_get_for_project(context, project_id)
key = 'consistencygroups'
return {key: groups}
def _sync_backup_gigabytes(
context,
project_id,
@ -697,7 +686,6 @@ QUOTA_SYNC_FUNCTIONS = {
'_sync_volumes': _sync_volumes,
'_sync_snapshots': _sync_snapshots,
'_sync_gigabytes': _sync_gigabytes,
'_sync_consistencygroups': _sync_consistencygroups,
'_sync_backups': _sync_backups,
'_sync_backup_gigabytes': _sync_backup_gigabytes,
'_sync_groups': _sync_groups,

View File

@ -39,9 +39,6 @@ quota_opts = [
cfg.IntOpt('quota_snapshots',
default=10,
help='Number of volume snapshots allowed per project'),
cfg.IntOpt('quota_consistencygroups',
default=10,
help='Number of consistencygroups allowed per project'),
cfg.IntOpt('quota_groups',
default=10,
help='Number of groups allowed per project'),
@ -910,30 +907,6 @@ class VolumeTypeQuotaEngine(QuotaEngine):
new_res)
class CGQuotaEngine(QuotaEngine):
"""Represent the consistencygroup quotas."""
@property
def resources(self):
"""Fetches all possible quota resources."""
result = {}
# Global quotas.
argses = [('consistencygroups', '_sync_consistencygroups',
'quota_consistencygroups'), ]
for args in argses:
resource = ReservableResource(*args)
result[resource.name] = resource
return result
def register_resource(self, resource):
raise NotImplementedError(_("Cannot register resource"))
def register_resources(self, resources):
raise NotImplementedError(_("Cannot register resources"))
class GroupQuotaEngine(QuotaEngine):
"""Represent the group quotas."""
@ -959,6 +932,5 @@ class GroupQuotaEngine(QuotaEngine):
QUOTAS = VolumeTypeQuotaEngine()
CGQUOTAS = CGQuotaEngine()
GROUP_QUOTAS = GroupQuotaEngine()
NON_QUOTA_KEYS = ['tenant_id', 'id']

View File

@ -369,6 +369,18 @@ class MigrationsWalk(
snapshots = db_utils.get_table(connection, 'snapshots')
self.assertFalse(snapshots.c.use_quota.nullable)
def _check_b7b88f50aab5(self, connection):
"""Test consistencygroups quota was removed."""
quota_classes = db_utils.get_table(connection, 'quota_classes')
res = connection.execute(
quota_classes.select().where(
sqlalchemy.and_(
quota_classes.c.resource == 'consistencygroups',
~quota_classes.c.deleted,
quota_classes.c.class_name == 'default')
)).all()
self.assertListEqual([], res)
# TODO: (D Release) Uncomment method _check_afd7494d43b7 and create a
# migration with hash afd7494d43b7 using the following command:
# $ tox -e venv -- alembic -c cinder/db/alembic.ini revision \