summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-09-14 21:13:27 +0000
committerGerrit Code Review <review@openstack.org>2016-09-14 21:13:27 +0000
commit8f2fa31d8a47e52b01bcf48771da83c23da464b1 (patch)
tree55ddfe5f1fd0d8eb0d1364f6222478ce4a70dfb2
parent4d54f96f9602c6247943b65f8e6f23656e5b1976 (diff)
parent10487a14a3673d4a28a4ea85a62619e69d5c669b (diff)
Merge "Fix allow/deny error message and race in migration"3.0.0.0rc13.0.0
-rw-r--r--manila/share/api.py30
-rw-r--r--manila/share/migration.py4
-rw-r--r--manila/tests/share/test_migration.py4
-rw-r--r--releasenotes/notes/migration-access-fix-71a0f52ea7a152a3.yaml7
4 files changed, 17 insertions, 28 deletions
diff --git a/manila/share/api.py b/manila/share/api.py
index 5bb2449..d3f7e0f 100644
--- a/manila/share/api.py
+++ b/manila/share/api.py
@@ -1345,20 +1345,7 @@ class API(base.Base):
1345 policy.check_policy(ctx, 'share', 'allow_access') 1345 policy.check_policy(ctx, 'share', 'allow_access')
1346 share = self.db.share_get(ctx, share['id']) 1346 share = self.db.share_get(ctx, share['id'])
1347 if share['status'] != constants.STATUS_AVAILABLE: 1347 if share['status'] != constants.STATUS_AVAILABLE:
1348 if not (share['status'] in (constants.STATUS_MIGRATING, 1348 msg = _("Share status must be %s") % constants.STATUS_AVAILABLE
1349 constants.STATUS_MIGRATING_TO) and
1350 share['task_state'] in (
1351 constants.TASK_STATE_DATA_COPYING_ERROR,
1352 constants.TASK_STATE_MIGRATION_ERROR,
1353 constants.TASK_STATE_MIGRATION_DRIVER_PHASE1_DONE,
1354 constants.TASK_STATE_DATA_COPYING_COMPLETED)):
1355 msg = _("Share status must be %(available)s, or %(migrating)s "
1356 "while first phase of migration is completed.") % {
1357 'available': constants.STATUS_AVAILABLE,
1358 'migrating': constants.STATUS_MIGRATING
1359 }
1360 else:
1361 msg = _("Share status must be %s") % constants.STATUS_AVAILABLE
1362 raise exception.InvalidShare(reason=msg) 1349 raise exception.InvalidShare(reason=msg)
1363 values = { 1350 values = {
1364 'share_id': share['id'], 1351 'share_id': share['id'],
@@ -1430,20 +1417,7 @@ class API(base.Base):
1430 msg = _("Share doesn't have any instances") 1417 msg = _("Share doesn't have any instances")
1431 raise exception.InvalidShare(reason=msg) 1418 raise exception.InvalidShare(reason=msg)
1432 if share['status'] != constants.STATUS_AVAILABLE: 1419 if share['status'] != constants.STATUS_AVAILABLE:
1433 if not (share['status'] in (constants.STATUS_MIGRATING, 1420 msg = _("Share status must be %s") % constants.STATUS_AVAILABLE
1434 constants.STATUS_MIGRATING_TO) and
1435 share['task_state'] in (
1436 constants.TASK_STATE_DATA_COPYING_ERROR,
1437 constants.TASK_STATE_MIGRATION_ERROR,
1438 constants.TASK_STATE_MIGRATION_DRIVER_PHASE1_DONE,
1439 constants.TASK_STATE_DATA_COPYING_COMPLETED)):
1440 msg = _("Share status must be %(available)s, or %(migrating)s "
1441 "while first phase of migration is completed.") % {
1442 'available': constants.STATUS_AVAILABLE,
1443 'migrating': constants.STATUS_MIGRATING
1444 }
1445 else:
1446 msg = _("Share status must be %s") % constants.STATUS_AVAILABLE
1447 raise exception.InvalidShare(reason=msg) 1421 raise exception.InvalidShare(reason=msg)
1448 1422
1449 for share_instance in share.instances: 1423 for share_instance in share.instances:
diff --git a/manila/share/migration.py b/manila/share/migration.py
index 67bbae4..e45cc65 100644
--- a/manila/share/migration.py
+++ b/manila/share/migration.py
@@ -194,6 +194,10 @@ class ShareMigrationHelper(object):
194 LOG.debug("Restoring all of share %s access rules according to " 194 LOG.debug("Restoring all of share %s access rules according to "
195 "DB.", self.share['id']) 195 "DB.", self.share['id'])
196 196
197 # refresh share instance
198 new_share_instance = self.db.share_instance_get(
199 self.context, new_share_instance['id'], with_share_data=True)
200
197 self.api.allow_access_to_instance(self.context, new_share_instance, 201 self.api.allow_access_to_instance(self.context, new_share_instance,
198 rules) 202 rules)
199 utils.wait_for_access_update( 203 utils.wait_for_access_update(
diff --git a/manila/tests/share/test_migration.py b/manila/tests/share/test_migration.py
index 2cf4f54..0429f09 100644
--- a/manila/tests/share/test_migration.py
+++ b/manila/tests/share/test_migration.py
@@ -345,6 +345,8 @@ class ShareMigrationHelperTestCase(test.TestCase):
345 access_level='rw') 345 access_level='rw')
346 346
347 # mocks 347 # mocks
348 self.mock_object(db, 'share_instance_get',
349 mock.Mock(return_value=new_share_instance))
348 self.mock_object(db, 'share_instance_access_copy') 350 self.mock_object(db, 'share_instance_access_copy')
349 self.mock_object(db, 'share_access_get_all_for_instance', 351 self.mock_object(db, 'share_access_get_all_for_instance',
350 mock.Mock(return_value=[access])) 352 mock.Mock(return_value=[access]))
@@ -355,6 +357,8 @@ class ShareMigrationHelperTestCase(test.TestCase):
355 self.helper.apply_new_access_rules(new_share_instance) 357 self.helper.apply_new_access_rules(new_share_instance)
356 358
357 # asserts 359 # asserts
360 db.share_instance_get.assert_called_once_with(
361 self.context, new_share_instance['id'], with_share_data=True)
358 db.share_instance_access_copy(self.context, self.share['id'], 362 db.share_instance_access_copy(self.context, self.share['id'],
359 new_share_instance['id']) 363 new_share_instance['id'])
360 db.share_access_get_all_for_instance.assert_called_once_with( 364 db.share_access_get_all_for_instance.assert_called_once_with(
diff --git a/releasenotes/notes/migration-access-fix-71a0f52ea7a152a3.yaml b/releasenotes/notes/migration-access-fix-71a0f52ea7a152a3.yaml
new file mode 100644
index 0000000..b214c44
--- /dev/null
+++ b/releasenotes/notes/migration-access-fix-71a0f52ea7a152a3.yaml
@@ -0,0 +1,7 @@
1---
2fixes:
3 - Fixed access_allow and access_deny displaying incorrect error
4 message during migration of a share.
5 - Fixed access rule concurrency in migration that was preventing
6 new rules from being added to the migrated share.
7