Fix metadata's soft-delete error when deleting shares
Currently we don't soft-delete metadata when deleting shares, fix it. Change-Id: Iad2031dab2fb6556d45fffb1cadee242ea668133 Closes-Bug: #1657033
This commit is contained in:
parent
8bdf0d476d
commit
0ec71e29b2
@ -1205,8 +1205,10 @@ def share_instance_delete(context, instance_id, session=None):
|
||||
instance_ref.soft_delete(session=session, update_status=True)
|
||||
share = share_get(context, instance_ref['share_id'], session=session)
|
||||
if len(share.instances) == 0:
|
||||
share.soft_delete(session=session)
|
||||
share_access_delete_all_by_share(context, share['id'])
|
||||
session.query(models.ShareMetadata).filter_by(
|
||||
share_id=share['id']).soft_delete()
|
||||
share.soft_delete(session=session)
|
||||
|
||||
|
||||
def _set_instances_share_data(context, instances, session):
|
||||
|
@ -194,10 +194,15 @@ class ShareDatabaseAPITestCase(test.TestCase):
|
||||
def test_share_instance_delete_with_share(self):
|
||||
share = db_utils.create_share()
|
||||
|
||||
self.assertIsNotNone(db_api.share_get(self.ctxt, share['id']))
|
||||
self.assertIsNotNone(db_api.share_metadata_get(self.ctxt, share['id']))
|
||||
|
||||
db_api.share_instance_delete(self.ctxt, share.instance['id'])
|
||||
|
||||
self.assertRaises(exception.NotFound, db_api.share_get,
|
||||
self.ctxt, share['id'])
|
||||
self.assertRaises(exception.NotFound, db_api.share_metadata_get,
|
||||
self.ctxt, share['id'])
|
||||
|
||||
def test_share_instance_get(self):
|
||||
share = db_utils.create_share()
|
||||
|
@ -0,0 +1,4 @@
|
||||
---
|
||||
fixes:
|
||||
- Fixed the error that share metadata records are not soft-deleted
|
||||
when deleting a share.
|
Loading…
Reference in New Issue
Block a user