diff options
| author | Rick Harris <rconradharris@gmail.com> | 2013-05-01 21:47:35 +0000 |
|---|---|---|
| committer | Rick Harris <rconradharris@gmail.com> | 2013-05-01 21:47:35 +0000 |
| commit | b6aac988e46147154d49e938ecf9b67831613636 (patch) | |
| tree | 9667733334ed7f76f3c60386dbdb8da8678edc3f | |
| parent | 423289d50d92cf4b780a11c2c3da4e1dbbd865f2 (diff) | |
xenapi: Don't swallow missing SR exception
The existing code would catch a missing SR exception and bail out of the
`update_status` method before finishing, causing required keys to be missing.
The end-result was code breaking later on when it tried to access these keys.
Since an SR is required to generate these required stats keys, we shouldn't
swallow the StorageRepositoryNotFound exception and instead should fail-fast.
Fixes bug 1175357
Change-Id: I3d65ae807fb2d86277bc0061c1967a87792b6662
| -rw-r--r-- | nova/tests/test_xenapi.py | 9 | ||||
| -rw-r--r-- | nova/virt/xenapi/host.py | 8 |
2 files changed, 10 insertions, 7 deletions
diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py index 9919fc138..3490a5dbf 100644 --- a/nova/tests/test_xenapi.py +++ b/nova/tests/test_xenapi.py @@ -1639,6 +1639,15 @@ class XenAPIHostTestCase(stubs.XenAPITestBase): self.assertEquals(stats['host_memory_overhead'], 20) self.assertEquals(stats['host_memory_free'], 30) self.assertEquals(stats['host_memory_free_computed'], 40) + self.assertEquals(stats['hypervisor_hostname'], 'fake-xenhost') + + def test_host_state_missing_sr(self): + def fake_safe_find_sr(session): + raise exception.StorageRepositoryNotFound('not there') + + self.stubs.Set(vm_utils, 'safe_find_sr', fake_safe_find_sr) + self.assertRaises(exception.StorageRepositoryNotFound, + self.conn.get_host_stats) def _test_host_action(self, method, action, expected=None): result = method('host', action) diff --git a/nova/virt/xenapi/host.py b/nova/virt/xenapi/host.py index 0abcf7444..258e4d145 100644 --- a/nova/virt/xenapi/host.py +++ b/nova/virt/xenapi/host.py @@ -148,13 +148,7 @@ class HostState(object): LOG.debug(_("Updating host stats")) data = call_xenhost(self._session, "host_data", {}) if data: - try: - # Get the SR usage - sr_ref = vm_utils.safe_find_sr(self._session) - except exception.NotFound as e: - # No SR configured - LOG.error(_("Unable to get SR for this host: %s") % e) - return + sr_ref = vm_utils.safe_find_sr(self._session) self._session.call_xenapi("SR.scan", sr_ref) sr_rec = self._session.call_xenapi("SR.get_record", sr_ref) total = int(sr_rec["physical_size"]) |
