Merge "Check share network for share groups before deletion"

This commit is contained in:
Zuul 2024-04-24 01:25:30 +00:00 committed by Gerrit Code Review
commit 2c95d47b97
3 changed files with 21 additions and 3 deletions

View File

@ -92,6 +92,15 @@ class ShareNetworkSubnetController(wsgi.Controller,
LOG.error(msg) LOG.error(msg)
raise exc.HTTPConflict(explanation=msg) raise exc.HTTPConflict(explanation=msg)
share_groups = db_api.share_group_get_all_by_share_server(
context, share_server['id'])
if share_groups:
msg = _("Cannot delete share network subnet %(id)s, it has "
"one or more share groups.") % {
'id': share_network_subnet_id}
LOG.error(msg)
raise exc.HTTPConflict(explanation=msg)
# NOTE(silvacarlose): Do not allow the deletion of any share server # NOTE(silvacarlose): Do not allow the deletion of any share server
# if any of them has the flag is_auto_deletable = False # if any of them has the flag is_auto_deletable = False
if not self._all_share_servers_are_auto_deletable( if not self._all_share_servers_are_auto_deletable(

View File

@ -1142,9 +1142,11 @@ class ShareServer(BASE, ManilaBase):
'ShareInstance.deleted == "False")') 'ShareInstance.deleted == "False")')
share_groups = orm.relationship( share_groups = orm.relationship(
"ShareGroup", backref='share_server', primaryjoin='and_(' "ShareGroup",
'ShareServer.id == ShareGroup.share_server_id,' backref='share_server',
'ShareGroup.deleted == "False")') primaryjoin='and_('
'ShareServer.id == ShareGroup.share_server_id,'
'ShareGroup.deleted == "False")')
_backend_details = orm.relationship( _backend_details = orm.relationship(
"ShareServerBackendDetails", "ShareServerBackendDetails",

View File

@ -0,0 +1,7 @@
---
fixes:
- |
Fixed an issue that allowed share network subnets to be deleted when they
were still related to a share group. An exception will now be raised when
Manila identify such existing relationship. For more details, please refer
to `Launchpad Bug 2004212 <https://bugs.launchpad.net/manila/+bug/2004212>`_.