]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix getting out-of-date volume operation state issue for VNX
authorXi Yang <xi.yang@emc.com>
Wed, 1 Jul 2015 07:50:27 +0000 (03:50 -0400)
committerXi Yang <xi.yang@emc.com>
Mon, 6 Jul 2015 06:39:28 +0000 (02:39 -0400)
The driver tries to get a volume's operation state with no polling
in the function wait_until_lun_ready_for_ops, that means the driver
may get out-of-date data. For example, if a volume has just changed
to 'Preparing' state, the function may get the state as 'Ready' and
report that the volume is ready to use. The fix is to get the volume
state with polling at the first time, then the driver would report
the right state of the volume.

Change-Id: I07aa89c33df4935716dbb35d3cfcdbc0e9964e0e
Closes-Bug: #1470041

cinder/tests/unit/test_emc_vnxdirect.py
cinder/volume/drivers/emc/emc_vnx_cli.py

index db07385d730d7fccb110bf8dd5189d6c4c8972b7..ba163f49066296983e284c8f05cea676dc5b41b6 100644 (file)
@@ -1715,7 +1715,7 @@ Time Remaining:  0 second(s)
         expected = [mock.call(*self.testData.SNAP_CREATE_CMD('snapshot1'),
                               poll=False),
                     mock.call(*self.testData.LUN_PROPERTY_ALL_CMD('vol1'),
-                              poll=False),
+                              poll=True),
                     mock.call(*self.testData.LUN_PROPERTY_ALL_CMD('vol1'),
                               poll=False),
                     mock.call(*self.testData.LUN_PROPERTY_ALL_CMD('vol1'),
@@ -2440,7 +2440,7 @@ Time Remaining:  0 second(s)
         expected = [mock.call(*self.testData.LUN_EXTEND_CMD('vol1', 2),
                               poll=False),
                     mock.call(*self.testData.LUN_PROPERTY_ALL_CMD('vol1'),
-                              poll=False),
+                              poll=True),
                     mock.call(*self.testData.LUN_PROPERTY_ALL_CMD('vol1'),
                               poll=False),
                     mock.call(*self.testData.LUN_PROPERTY_ALL_CMD('vol1'),
index 69f68e344cbf1d6a847030b904b31c317b39d1fa..840c28cf85cf1bdfe15ff2c0fbdbbe297f77c445 100644 (file)
@@ -1219,14 +1219,18 @@ class CommandLineHelper(object):
         return data
 
     def get_lun_current_ops_state(self, name, poll=False):
-        data = self.get_lun_by_name(name, poll=False)
+        data = self.get_lun_by_name(name, poll=poll)
         return data[self.LUN_OPERATION.key]
 
     def wait_until_lun_ready_for_ops(self, name):
         def is_lun_ready_for_ops():
             data = self.get_lun_current_ops_state(name, False)
             return data == 'None'
-        self._wait_for_a_condition(is_lun_ready_for_ops)
+        # Get the volume's latest operation state by polling.
+        # Otherwise, the operation state may be out of date.
+        ops = self.get_lun_current_ops_state(name, True)
+        if ops != 'None':
+            self._wait_for_a_condition(is_lun_ready_for_ops)
 
     def get_pool(self, name, properties=POOL_ALL, poll=True):
         data = self.get_pool_properties(('-name', name),