RBD: Skip update_features when features = 0
librbd errors when update_features is called w/ features = 0 -- when this situation would occur, skip calling update_features. Closes-Bug: #1997980 Change-Id: Iab6a990ce7dee2c13deb4f46aeec0f46ffb7cd62
This commit is contained in:
parent
a92aa06e46
commit
6e08f15074
@ -3316,6 +3316,17 @@ class RBDTestCase(test.TestCase):
|
||||
{'provider_location':
|
||||
"{\"saved_features\":%s}" % image_features}, ret)
|
||||
|
||||
@common_mocks
|
||||
def test_enable_multiattach_no_features(self):
|
||||
image = self.mock_proxy.return_value.__enter__.return_value
|
||||
image.features.return_value = 0
|
||||
|
||||
ret = self.driver._enable_multiattach(self.volume_a)
|
||||
|
||||
image.update_features.assert_not_called()
|
||||
|
||||
self.assertEqual({'provider_location': '{"saved_features":0}'}, ret)
|
||||
|
||||
@ddt.data(MULTIATTACH_FULL_FEATURES, MULTIATTACH_REDUCED_FEATURES)
|
||||
@common_mocks
|
||||
def test_disable_multiattach(self, features):
|
||||
@ -3329,6 +3340,18 @@ class RBDTestCase(test.TestCase):
|
||||
|
||||
self.assertEqual({'provider_location': None}, ret)
|
||||
|
||||
@common_mocks
|
||||
def test_disable_multiattach_no_features(self):
|
||||
image = self.mock_proxy.return_value.__enter__.return_value
|
||||
self.volume_a.provider_location = '{"saved_features": 0}'
|
||||
image.features.return_value = 0
|
||||
|
||||
ret = self.driver._disable_multiattach(self.volume_a)
|
||||
|
||||
image.update_features.assert_not_called()
|
||||
|
||||
self.assertEqual({'provider_location': None}, ret)
|
||||
|
||||
|
||||
class ManagedRBDTestCase(test_driver.BaseDriverTestCase):
|
||||
driver_name = "cinder.volume.drivers.rbd.RBDDriver"
|
||||
|
@ -965,7 +965,8 @@ class RBDDriver(driver.CloneableImageVD, driver.MigrateVD,
|
||||
with RBDVolumeProxy(self, vol_name) as image:
|
||||
image_features = image.features()
|
||||
change_features = self.MULTIATTACH_EXCLUSIONS & image_features
|
||||
image.update_features(change_features, False)
|
||||
if change_features != 0:
|
||||
image.update_features(change_features, False)
|
||||
|
||||
return {'provider_location':
|
||||
self._dumps({'saved_features': image_features})}
|
||||
@ -977,7 +978,8 @@ class RBDDriver(driver.CloneableImageVD, driver.MigrateVD,
|
||||
provider_location = json.loads(volume.provider_location)
|
||||
image_features = provider_location['saved_features']
|
||||
change_features = self.MULTIATTACH_EXCLUSIONS & image_features
|
||||
image.update_features(change_features, True)
|
||||
if change_features != 0:
|
||||
image.update_features(change_features, True)
|
||||
except IndexError:
|
||||
msg = "Could not find saved image features."
|
||||
raise RBDDriverException(reason=msg)
|
||||
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
`Bug #1997980 <https://bugs.launchpad.net/cinder/+bug/1997980>`_: RBD:
|
||||
Fixed failure to update rbd image features for multi-attach when
|
||||
features = 0.
|
Loading…
x
Reference in New Issue
Block a user