diff --git a/manila/share/api.py b/manila/share/api.py index 4a3bea0d39..08848cb3b4 100644 --- a/manila/share/api.py +++ b/manila/share/api.py @@ -1106,6 +1106,15 @@ class API(base.Base): LOG.error(msg) raise exception.Conflict(err=msg) + # TODO(ganso): We do not support migrating shares in or out of groups + # for now. + if share.get('share_group_id'): + msg = _('Share %s is a member of a group. This operation is not ' + 'currently supported for shares that are members of ' + 'groups.') % share['id'] + LOG.error(msg) + raise exception.InvalidShare(reason=msg) + # We only handle "available" share for now if share_instance['status'] != constants.STATUS_AVAILABLE: msg = _('Share instance %(instance_id)s status must be available, ' diff --git a/manila/tests/share/test_api.py b/manila/tests/share/test_api.py index 61e0ecfead..5086f18047 100644 --- a/manila/tests/share/test_api.py +++ b/manila/tests/share/test_api.py @@ -2644,6 +2644,18 @@ class ShareAPITestCase(test.TestCase): self.assertTrue(mock_log.error.called) self.assertFalse(mock_snapshot_get_call.called) + def test_migration_start_is_member_of_group(self): + group = db_utils.create_share_group() + share = db_utils.create_share( + host='fake@backend#pool', status=constants.STATUS_AVAILABLE, + share_group_id=group['id']) + mock_log = self.mock_object(share_api, 'LOG') + + self.assertRaises(exception.InvalidShare, self.api.migration_start, + self.context, share, 'fake_host', False, True, True, + True, True) + self.assertTrue(mock_log.error.called) + def test_migration_start_invalid_host(self): host = 'fake@backend#pool' share = db_utils.create_share( diff --git a/releasenotes/notes/bug-1660319-1660336-migration-share-groups-e66a1478634947ad.yaml b/releasenotes/notes/bug-1660319-1660336-migration-share-groups-e66a1478634947ad.yaml new file mode 100644 index 0000000000..2f76b8ff0e --- /dev/null +++ b/releasenotes/notes/bug-1660319-1660336-migration-share-groups-e66a1478634947ad.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - Shares can no longer be migrated while being + members of share groups. +