Handle VolumeBDMPathNotFound in _get_disk_over_committed_size_total

This handles the VolumeBDMPathNotFound error bubbling up from
_get_instance_disk_info during the update_available_resource periodic
task.

Related-Bug: #1371677

Change-Id: I10c20f3f5f96003fe69fcdc9133c661e6dc009b4
This commit is contained in:
Matt Riedemann 2014-09-19 13:47:42 -07:00
parent 9a570111d9
commit 76bc4ac549
2 changed files with 19 additions and 0 deletions

View File

@ -7722,6 +7722,17 @@ class LibvirtConnTestCase(test.TestCase):
self.assertEqual(21474836480, result)
mock_list.assert_called_with()
@mock.patch.object(libvirt_driver.LibvirtDriver, "_list_instance_domains",
return_value=[mock.MagicMock(name='foo')])
@mock.patch.object(libvirt_driver.LibvirtDriver, "_get_instance_disk_info",
side_effect=exception.VolumeBDMPathNotFound(path='bar'))
def test_disk_over_committed_size_total_bdm_not_found(self,
mock_get_disk_info,
mock_list_domains):
# Tests that we handle VolumeBDMPathNotFound gracefully.
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
self.assertEqual(0, drvr._get_disk_over_committed_size_total())
def test_cpu_info(self):
conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)

View File

@ -5743,6 +5743,14 @@ class LibvirtDriver(driver.ComputeDriver):
{'i_name': dom.name()})
else:
raise
except exception.VolumeBDMPathNotFound as e:
LOG.warn(_LW('Periodic task is updating the host stats, '
'it is trying to get disk info for %(i_name)s, '
'but the backing volume block device was removed '
'by concurrent operations such as resize. '
'Error: %(error)s'),
{'i_name': dom.name(),
'error': e})
# NOTE(gtt116): give other tasks a chance.
greenthread.sleep(0)
return disk_over_committed_size