From 320f6fd956150c5ab2244a87486aceb653ada29e Mon Sep 17 00:00:00 2001 From: Xi Yang Date: Wed, 1 Jul 2015 03:50:27 -0400 Subject: [PATCH] Fix getting out-of-date volume operation state issue for VNX 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 | 4 ++-- cinder/volume/drivers/emc/emc_vnx_cli.py | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cinder/tests/unit/test_emc_vnxdirect.py b/cinder/tests/unit/test_emc_vnxdirect.py index db07385d7..ba163f490 100644 --- a/cinder/tests/unit/test_emc_vnxdirect.py +++ b/cinder/tests/unit/test_emc_vnxdirect.py @@ -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'), diff --git a/cinder/volume/drivers/emc/emc_vnx_cli.py b/cinder/volume/drivers/emc/emc_vnx_cli.py index 69f68e344..840c28cf8 100644 --- a/cinder/volume/drivers/emc/emc_vnx_cli.py +++ b/cinder/volume/drivers/emc/emc_vnx_cli.py @@ -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), -- 2.45.2