block_device: Rollback volumes to in-use on DeviceDetachFailed

The call to os-roll_detaching was dropped when
I3800b466a50b1e5f5d1e8c8a963d9a6258af67ee started to catch and reraise
DeviceDetachFailed. This call is required to ensure a volume returns to
an in-use state when the instance is unable to detach.

Closes-Bug: #1786318
Change-Id: I6b3dc09acc6f360806ce0ef8c8a65addbf4a8c51
(cherry picked from commit 3a4b4b91b0)
This commit is contained in:
Lee Yarwood 2018-08-09 17:43:50 +01:00
parent ddc7c466d7
commit a890c34036
2 changed files with 3 additions and 0 deletions

View File

@ -248,6 +248,8 @@ class TestDriverBlockDevice(test.NoDBTestCase):
self.context, inst, vol_api, virt)
self.assertFalse(log.exception.called)
self.assertTrue(log.warning.called)
vol_api.roll_detaching.assert_called_once_with(self.context,
driver_bdm.volume_id)
def test_no_device_raises(self):
for name, cls in self.driver_classes.items():

View File

@ -322,6 +322,7 @@ class DriverVolumeBlockDevice(DriverBlockDevice):
with excutils.save_and_reraise_exception():
LOG.warning('Guest refused to detach volume %(vol)s',
{'vol': volume_id}, instance=instance)
volume_api.roll_detaching(context, volume_id)
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception('Failed to detach volume '