Fix quota rollback on retype failure
Currently quota rollback is not happening if retype fails with no valid host. We are passing reservation as None and the exception message is set to the actual reservation. Hence, a cryptic message is printed and the rollback is skipped. Change-Id: I80644330d2d7bf905c4a4800d54efa6951f07496 Closes-bug: #1616875
This commit is contained in:
@@ -266,8 +266,9 @@ class SchedulerManagerTestCase(test.TestCase):
|
||||
|
||||
@mock.patch('cinder.db.volume_update')
|
||||
@mock.patch('cinder.db.volume_attachment_get_all_by_volume_id')
|
||||
@mock.patch('cinder.quota.QUOTAS.rollback')
|
||||
def test_retype_volume_exception_returns_volume_state(
|
||||
self, _mock_vol_attachment_get, _mock_vol_update):
|
||||
self, quota_rollback, _mock_vol_attachment_get, _mock_vol_update):
|
||||
# Test NoValidHost exception behavior for retype.
|
||||
# Puts the volume in original state and eats the exception.
|
||||
volume = tests_utils.create_volume(self.context,
|
||||
@@ -279,8 +280,10 @@ class SchedulerManagerTestCase(test.TestCase):
|
||||
'/dev/fake')
|
||||
_mock_vol_attachment_get.return_value = [volume_attach]
|
||||
topic = 'fake_topic'
|
||||
reservations = mock.sentinel.reservations
|
||||
request_spec = {'volume_id': volume.id, 'volume_type': {'id': 3},
|
||||
'migration_policy': 'on-demand'}
|
||||
'migration_policy': 'on-demand',
|
||||
'quota_reservations': reservations}
|
||||
_mock_vol_update.return_value = {'status': 'in-use'}
|
||||
_mock_find_retype_host = mock.Mock(
|
||||
side_effect=exception.NoValidHost(reason=""))
|
||||
@@ -295,6 +298,7 @@ class SchedulerManagerTestCase(test.TestCase):
|
||||
_mock_find_retype_host.assert_called_once_with(self.context,
|
||||
request_spec, {},
|
||||
'on-demand')
|
||||
quota_rollback.assert_called_once_with(self.context, reservations)
|
||||
_mock_vol_update.assert_called_once_with(self.context, volume.id,
|
||||
{'status': 'in-use'})
|
||||
self.manager.driver.find_retype_host = orig_retype
|
||||
|
||||
Reference in New Issue
Block a user