Browse Source

Merge "Delete type access list when deleting types" into stable/queens

changes/29/726229/1
Zuul 1 month ago
committed by Gerrit Code Review
parent
commit
b738855bb9
3 changed files with 51 additions and 6 deletions
  1. +21
    -4
      manila/db/sqlalchemy/api.py
  2. +22
    -2
      manila/tests/db/sqlalchemy/test_api.py
  3. +8
    -0
      releasenotes/notes/bug-1870751-cleanup-share-type-and-group-type-project-access-when-deleted-4fcd49ba6e6c40bd.yaml

+ 21
- 4
manila/db/sqlalchemy/api.py View File

@@ -3928,10 +3928,22 @@ def share_type_destroy(context, id):
'gtypes': share_group_types_count}
LOG.error(msg, msg_args)
raise exception.ShareTypeInUse(share_type_id=id)
(model_query(context, models.ShareTypeExtraSpecs, session=session).
filter_by(share_type_id=id).soft_delete())
(model_query(context, models.ShareTypes, session=session).
filter_by(id=id).soft_delete())

model_query(
context, models.ShareTypeExtraSpecs, session=session
).filter_by(
share_type_id=id
).soft_delete()
model_query(
context, models.ShareTypeProjects, session=session
).filter_by(
share_type_id=id,
).soft_delete()
model_query(
context, models.ShareTypes, session=session
).filter_by(
id=id
).soft_delete()

# Destroy any quotas, usages and reservations for the share type:
quota_destroy_all_by_share_type(context, id)
@@ -4792,6 +4804,11 @@ def share_group_type_destroy(context, type_id):
).filter_by(
share_group_type_id=type_id,
).soft_delete()
model_query(
context, models.ShareGroupTypeProjects, session=session
).filter_by(
share_group_type_id=type_id,
).soft_delete()
model_query(
context, models.ShareGroupTypes, session=session
).filter_by(


+ 22
- 2
manila/tests/db/sqlalchemy/test_api.py View File

@@ -1139,6 +1139,12 @@ class ShareGroupTypeAPITestCase(test.TestCase):
name='orange', is_public=False, share_types=[share_type_1['id']],
group_specs={'dabo': 'allin', 'cadence': 'count'},
override_defaults=True)
db_api.share_group_type_access_add(self.ctxt,
share_group_type_1['id'],
"2018ndaetfigovnsaslcahfavmrpions")
db_api.share_group_type_access_add(self.ctxt,
share_group_type_1['id'],
"2016ndaetfigovnsaslcahfavmrpions")
share_group_type_2 = db_utils.create_share_group_type(
name='regalia', share_types=[share_type_2['id']])
if used_by_groups:
@@ -1164,6 +1170,9 @@ class ShareGroupTypeAPITestCase(test.TestCase):
self.assertDictMatch(
{}, db_api.share_group_type_specs_get(
self.ctxt, share_group_type_1['id']))
self.assertRaises(exception.ShareGroupTypeNotFound,
db_api.share_group_type_access_get_all,
self.ctxt, share_group_type_1['id'])
self.assertRaises(exception.ShareGroupTypeNotFound,
db_api.share_group_type_get,
self.ctxt, share_group_type_1['id'])
@@ -2979,8 +2988,16 @@ class ShareTypeAPITestCase(test.TestCase):
def test_share_type_destroy_in_use(self, used_by_shares,
used_by_group_types):
share_type_1 = db_utils.create_share_type(
name='orange', extra_specs={'somekey': 'someval'})
share_type_2 = db_utils.create_share_type(name='regalia')
name='orange', extra_specs={'somekey': 'someval'},
is_public=False, override_defaults=True)
share_type_2 = db_utils.create_share_type(
name='regalia', override_defaults=True)
db_api.share_type_access_add(self.ctxt,
share_type_1['id'],
"2018ndaetfigovnsaslcahfavmrpions")
db_api.share_type_access_add(self.ctxt,
share_type_1['id'],
"2016ndaetfigovnsaslcahfavmrpions")
if used_by_shares:
share_1 = db_utils.create_share(share_type_id=share_type_1['id'])
db_utils.create_share(share_type_id=share_type_2['id'])
@@ -3013,6 +3030,9 @@ class ShareTypeAPITestCase(test.TestCase):
self.assertDictMatch(
{}, db_api.share_type_extra_specs_get(
self.ctxt, share_type_1['id']))
self.assertRaises(exception.ShareTypeNotFound,
db_api.share_type_access_get_all,
self.ctxt, share_type_1['id'])
self.assertRaises(exception.ShareTypeNotFound,
db_api.share_type_get,
self.ctxt, share_type_1['id'])


+ 8
- 0
releasenotes/notes/bug-1870751-cleanup-share-type-and-group-type-project-access-when-deleted-4fcd49ba6e6c40bd.yaml View File

@@ -0,0 +1,8 @@
---
fixes:
- |
Fixed the cleanup for private share types and share group types to include
clearing out the database entries recording project specific access
rules to these types. See
`Launchpad bug 1870751 <https://launchpad.net/bugs/1870751>`_ for more
details.

Loading…
Cancel
Save