Browse Source

Merge "Fix allow/deny error message and race in migration"

Jenkins 2 years ago
parent
commit
8f2fa31d8a

+ 2
- 28
manila/share/api.py View File

@@ -1345,20 +1345,7 @@ class API(base.Base):
1345 1345
         policy.check_policy(ctx, 'share', 'allow_access')
1346 1346
         share = self.db.share_get(ctx, share['id'])
1347 1347
         if share['status'] != constants.STATUS_AVAILABLE:
1348
-            if not (share['status'] in (constants.STATUS_MIGRATING,
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
1348
+            msg = _("Share status must be %s") % constants.STATUS_AVAILABLE
1362 1349
             raise exception.InvalidShare(reason=msg)
1363 1350
         values = {
1364 1351
             'share_id': share['id'],
@@ -1430,20 +1417,7 @@ class API(base.Base):
1430 1417
             msg = _("Share doesn't have any instances")
1431 1418
             raise exception.InvalidShare(reason=msg)
1432 1419
         if share['status'] != constants.STATUS_AVAILABLE:
1433
-            if not (share['status'] in (constants.STATUS_MIGRATING,
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
1420
+            msg = _("Share status must be %s") % constants.STATUS_AVAILABLE
1447 1421
             raise exception.InvalidShare(reason=msg)
1448 1422
 
1449 1423
         for share_instance in share.instances:

+ 4
- 0
manila/share/migration.py View File

@@ -194,6 +194,10 @@ class ShareMigrationHelper(object):
194 194
             LOG.debug("Restoring all of share %s access rules according to "
195 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 201
             self.api.allow_access_to_instance(self.context, new_share_instance,
198 202
                                               rules)
199 203
             utils.wait_for_access_update(

+ 4
- 0
manila/tests/share/test_migration.py View File

@@ -345,6 +345,8 @@ class ShareMigrationHelperTestCase(test.TestCase):
345 345
                                         access_level='rw')
346 346
 
347 347
         # mocks
348
+        self.mock_object(db, 'share_instance_get',
349
+                         mock.Mock(return_value=new_share_instance))
348 350
         self.mock_object(db, 'share_instance_access_copy')
349 351
         self.mock_object(db, 'share_access_get_all_for_instance',
350 352
                          mock.Mock(return_value=[access]))
@@ -355,6 +357,8 @@ class ShareMigrationHelperTestCase(test.TestCase):
355 357
         self.helper.apply_new_access_rules(new_share_instance)
356 358
 
357 359
         # asserts
360
+        db.share_instance_get.assert_called_once_with(
361
+            self.context, new_share_instance['id'], with_share_data=True)
358 362
         db.share_instance_access_copy(self.context, self.share['id'],
359 363
                                       new_share_instance['id'])
360 364
         db.share_access_get_all_for_instance.assert_called_once_with(

+ 7
- 0
releasenotes/notes/migration-access-fix-71a0f52ea7a152a3.yaml View File

@@ -0,0 +1,7 @@
1
+---
2
+fixes:
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
+

Loading…
Cancel
Save