From 26c803ea95b7e9b00822a867fc4b9bc04a4f10d4 Mon Sep 17 00:00:00 2001 From: Rodrigo Barbieri Date: Wed, 1 Feb 2017 15:41:03 -0200 Subject: [PATCH] Blocked migration of shares within share groups In Ocata, coordination between share migration and share groups features was not implemented. So, restrict its usage for now. APIImpact Change-Id: Id15453590685aa9c7788e79a33ca98b4dcc8a3ea Closes-bug: #1660336 Closes-bug: #1660319 --- manila/share/api.py | 9 +++++++++ manila/tests/share/test_api.py | 12 ++++++++++++ ...0336-migration-share-groups-e66a1478634947ad.yaml | 5 +++++ 3 files changed, 26 insertions(+) create mode 100644 releasenotes/notes/bug-1660319-1660336-migration-share-groups-e66a1478634947ad.yaml 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. +