Validate pci_passthrough_whitelist when starting n-cpu
Loading up CONF.pci_passthrough_whitelist in the Whitelist object performs a bunch of validation and can fail in several different ways (invalid json, invalid values, invalid combinations of keys, devices not found, etc). This happens today when creating the PciDevTracker in the ResourceTracker when updating available resources. If the configuration is bad, it kills the periodic task to update available resources on the compute node. We should just load up the pci_passthrough_whitelist (if set) when starting the nova-compute service so we can fail fast and kill the service on any misconfiguration rather than run with a broken service. Change-Id: If50fb837b490042bb5ef20e9ad843b28f871a44e Closes-Bug: #1603034
This commit is contained in:
parent
f6f4003dfd
commit
3a61ae35d4
|
@ -88,6 +88,7 @@ from nova.objects import base as obj_base
|
|||
from nova.objects import fields
|
||||
from nova.objects import instance as obj_instance
|
||||
from nova.objects import migrate_data as migrate_data_obj
|
||||
from nova.pci import whitelist
|
||||
from nova import rpc
|
||||
from nova import safe_utils
|
||||
from nova.scheduler import client as scheduler_client
|
||||
|
@ -1119,6 +1120,17 @@ class ComputeManager(manager.Manager):
|
|||
|
||||
def init_host(self):
|
||||
"""Initialization for a standalone compute service."""
|
||||
|
||||
if CONF.pci_passthrough_whitelist:
|
||||
# Simply loading the PCI passthrough whitelist will do a bunch of
|
||||
# validation that would otherwise wait until the PciDevTracker is
|
||||
# constructed when updating available resources for the compute
|
||||
# node(s) in the resource tracker, effectively killing that task.
|
||||
# So load up the whitelist when starting the compute service to
|
||||
# flush any invalid configuration early so we can kill the service
|
||||
# if the configuration is wrong.
|
||||
whitelist.Whitelist(CONF.pci_passthrough_whitelist)
|
||||
|
||||
self.driver.init_host(host=self.host)
|
||||
context = nova.context.get_admin_context()
|
||||
instances = objects.InstanceList.get_by_host(
|
||||
|
|
|
@ -2764,6 +2764,15 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
|
|||
msg = mock_log.warning.call_args_list[0]
|
||||
self.assertIn('appears to not be owned by this host', msg[0][0])
|
||||
|
||||
def test_init_host_pci_passthrough_whitelist_validation_failure(self):
|
||||
# Tests that we fail init_host if there is a pci_passthrough_whitelist
|
||||
# configured incorrectly.
|
||||
self.flags(pci_passthrough_whitelist=[
|
||||
# it's invalid to specify both in the same devspec
|
||||
jsonutils.dumps({'address': 'foo', 'devname': 'bar'})])
|
||||
self.assertRaises(exception.PciDeviceInvalidDeviceName,
|
||||
self.compute.init_host)
|
||||
|
||||
@mock.patch('nova.compute.manager.ComputeManager._instance_update')
|
||||
def test_error_out_instance_on_exception_not_implemented_err(self,
|
||||
inst_update_mock):
|
||||
|
|
Loading…
Reference in New Issue