Merge "RBD: Run flatten in a different thread when cloning a volume" into stable/victoria
This commit is contained in:
commit
03a7cf6f12
|
@ -1173,6 +1173,9 @@ class RBDTestCase(test.TestCase):
|
||||||
def test_create_cloned_volume_w_flatten(self, mock_enable_repl):
|
def test_create_cloned_volume_w_flatten(self, mock_enable_repl):
|
||||||
self.cfg.rbd_max_clone_depth = 1
|
self.cfg.rbd_max_clone_depth = 1
|
||||||
|
|
||||||
|
client = self.mock_client.return_value
|
||||||
|
client.__enter__.return_value = client
|
||||||
|
|
||||||
with mock.patch.object(self.driver, '_get_clone_info') as \
|
with mock.patch.object(self.driver, '_get_clone_info') as \
|
||||||
mock_get_clone_info:
|
mock_get_clone_info:
|
||||||
mock_get_clone_info.return_value = (
|
mock_get_clone_info.return_value = (
|
||||||
|
@ -1202,9 +1205,13 @@ class RBDTestCase(test.TestCase):
|
||||||
.assert_called_once_with('.'.join(
|
.assert_called_once_with('.'.join(
|
||||||
(self.volume_b.name, 'clone_snap'))))
|
(self.volume_b.name, 'clone_snap'))))
|
||||||
|
|
||||||
# We expect the driver to close both volumes, so 2 is expected
|
self.mock_proxy.assert_called_once_with(
|
||||||
|
self.driver, self.volume_b.name,
|
||||||
|
client=client, ioctx=client.ioctx)
|
||||||
|
|
||||||
|
# Source volume is closed by direct call of close()
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
2, self.mock_rbd.Image.return_value.close.call_count)
|
1, self.mock_rbd.Image.return_value.close.call_count)
|
||||||
self.assertTrue(mock_get_clone_depth.called)
|
self.assertTrue(mock_get_clone_depth.called)
|
||||||
mock_enable_repl.assert_not_called()
|
mock_enable_repl.assert_not_called()
|
||||||
|
|
||||||
|
|
|
@ -736,11 +736,13 @@ class RBDDriver(driver.CloneableImageVD, driver.MigrateVD,
|
||||||
LOG.info("maximum clone depth (%d) has been reached - "
|
LOG.info("maximum clone depth (%d) has been reached - "
|
||||||
"flattening dest volume",
|
"flattening dest volume",
|
||||||
self.configuration.rbd_max_clone_depth)
|
self.configuration.rbd_max_clone_depth)
|
||||||
dest_volume = self.rbd.Image(client.ioctx, dest_name)
|
|
||||||
|
# Flatten destination volume
|
||||||
try:
|
try:
|
||||||
# Flatten destination volume
|
with RBDVolumeProxy(self, dest_name, client=client,
|
||||||
LOG.debug("flattening dest volume %s", dest_name)
|
ioctx=client.ioctx) as dest_volume:
|
||||||
dest_volume.flatten()
|
LOG.debug("flattening dest volume %s", dest_name)
|
||||||
|
dest_volume.flatten()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
msg = (_("Failed to flatten volume %(volume)s with "
|
msg = (_("Failed to flatten volume %(volume)s with "
|
||||||
"error: %(error)s.") %
|
"error: %(error)s.") %
|
||||||
|
@ -749,8 +751,6 @@ class RBDDriver(driver.CloneableImageVD, driver.MigrateVD,
|
||||||
LOG.exception(msg)
|
LOG.exception(msg)
|
||||||
src_volume.close()
|
src_volume.close()
|
||||||
raise exception.VolumeBackendAPIException(data=msg)
|
raise exception.VolumeBackendAPIException(data=msg)
|
||||||
finally:
|
|
||||||
dest_volume.close()
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# remove temporary snap
|
# remove temporary snap
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
RBD driver `Bug #1898918
|
||||||
|
<https://bugs.launchpad.net/cinder/+bug/1898918>`_: Fix thread block caused
|
||||||
|
by the flatten operation during cloning a volume. Now the flatten operation
|
||||||
|
is executed in a different thread.
|
Loading…
Reference in New Issue