summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpkholkin <pkholkin@mirantis.com>2014-09-12 19:31:54 +0400
committerpkholkin <pkholkin@mirantis.com>2015-02-02 19:47:12 +0400
commitdbc348d296cbbb03650f77f6ef29b55635162c15 (patch)
tree418d44adb72d104a342faf839888fb6e23f0e4d2
parent0e00893a8b4dcf50a709e4b0305810dc7b935ada (diff)
downloadnova-dbc348d296cbbb03650f77f6ef29b55635162c15.tar.gz
Fix libvirt watchdog support
Using the flavor extra_specs property "hw_watchdog_action" was broken. Scheduling of a new instance always failed with NoValidHostFound error because of ComputeCapabilitiesFilter, which treated this property as a host capability to be checked. Commit f0ff4d51057080e769407e873e5ed212f15b773d caused the problem. To fix this watchdog_action property is put into 'hw:' scope, so that it will be ignored by ComputeCapabilitiesFilter in scheduler and handled in libvirt driver. The doc must be fixed accordingly. Now driver accepts both 'hw_watchdog_action' and 'hw:watchdog_action', tests were edited for these cases. Were added TODO items to delete the compat code in L release. DocImpact Closes-Bug: #1367344 Conflicts: nova/tests/virt/libvirt/test_libvirt.py Change-Id: Ic5344ec34a130ee5a0ed2c7348af0b9d79e3508e (cherry picked from commit 79bfb1bf343484e98aa36dcc663a5370baf4cab7)
-rw-r--r--nova/tests/virt/libvirt/test_libvirt.py17
-rw-r--r--nova/virt/libvirt/driver.py12
2 files changed, 24 insertions, 5 deletions
diff --git a/nova/tests/virt/libvirt/test_libvirt.py b/nova/tests/virt/libvirt/test_libvirt.py
index 2478e8eea7..5a3f414a99 100644
--- a/nova/tests/virt/libvirt/test_libvirt.py
+++ b/nova/tests/virt/libvirt/test_libvirt.py
@@ -1445,7 +1445,8 @@ class LibvirtConnTestCase(test.TestCase):
self.assertEqual("none", cfg.devices[7].action)
- def test_get_guest_config_with_watchdog_action_through_flavor(self):
+ def _test_get_guest_config_with_watchdog_action_flavor(self,
+ hw_watchdog_action="hw:watchdog_action"):
self.flags(virt_type='kvm', group='libvirt')
conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
@@ -1455,7 +1456,7 @@ class LibvirtConnTestCase(test.TestCase):
db.flavor_extra_specs_update_or_create(
self.context,
flavor['flavorid'],
- {'hw_watchdog_action': 'none'})
+ {hw_watchdog_action: 'none'})
instance_ref = db.instance_create(self.context, self.test_instance)
@@ -1466,7 +1467,7 @@ class LibvirtConnTestCase(test.TestCase):
db.flavor_extra_specs_delete(self.context,
flavor['flavorid'],
- 'hw_watchdog_action')
+ hw_watchdog_action)
self.assertEqual(8, len(cfg.devices))
self.assertIsInstance(cfg.devices[0],
@@ -1488,6 +1489,16 @@ class LibvirtConnTestCase(test.TestCase):
self.assertEqual("none", cfg.devices[7].action)
+ def test_get_guest_config_with_watchdog_action_through_flavor(self):
+ self._test_get_guest_config_with_watchdog_action_flavor()
+
+ # TODO(pkholkin): the test accepting old property name 'hw_watchdog_action'
+ # should be removed in L release
+ def test_get_guest_config_with_watchdog_action_through_flavor_no_scope(
+ self):
+ self._test_get_guest_config_with_watchdog_action_flavor(
+ hw_watchdog_action="hw_watchdog_action")
+
def test_get_guest_config_with_watchdog_action_meta_overrides_flavor(self):
self.flags(virt_type='kvm', group='libvirt')
diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py
index 43f4762163..8a0b82d9a9 100644
--- a/nova/virt/libvirt/driver.py
+++ b/nova/virt/libvirt/driver.py
@@ -3441,8 +3441,16 @@ class LibvirtDriver(driver.ComputeDriver):
raise exception.PciDeviceUnsupportedHypervisor(
type=CONF.libvirt.virt_type)
- watchdog_action = flavor.extra_specs.get('hw_watchdog_action',
- 'disabled')
+ if 'hw_watchdog_action' in flavor.extra_specs:
+ LOG.warn(_LW('Old property name "hw_watchdog_action" is now '
+ 'deprecated and will be removed in L release. '
+ 'Use updated property name '
+ '"hw:watchdog_action" instead'))
+ # TODO(pkholkin): accepting old property name 'hw_watchdog_action'
+ # should be removed in L release
+ watchdog_action = (flavor.extra_specs.get('hw_watchdog_action') or
+ flavor.extra_specs.get('hw:watchdog_action')
+ or 'disabled')
if (image_meta is not None and
image_meta.get('properties', {}).get('hw_watchdog_action')):
watchdog_action = image_meta['properties']['hw_watchdog_action']