Avoid crashing while getting libvirt capabilities with unknown arch names
In _get_instance_capabilities() we get a list of host capabilities and then build a list of arches supported by the virt type of an instance to arrive at the list of possibilities for the instance. We check each of those against our enum, but fail to gracefully skip unsupported values should we encounter one. This patch makes that graceful, and also introduces an unsupported arch to the test stub to make sure we always skip it. Note that we do not warn because this happens once per instance in a periodic task, and since the situation is caused by a (somewhat permanent) mismatch of libvirt and nova version support, isn't something that needs to be remedied by an operator. Closes-Bug: #1820125 Change-Id: I5d95bd50279a6bf903a5793ad5f3ae9d06f085f4
This commit is contained in:
parent
63e5cba88a
commit
71df650d0a
@ -16075,6 +16075,14 @@ class LibvirtConnTestCase(test.NoDBTestCase,
|
||||
guest.domtype = ['kvm']
|
||||
caps.guests.append(guest)
|
||||
|
||||
# Include one that is not known to nova to make sure it
|
||||
# does not trip us up.
|
||||
guest = vconfig.LibvirtConfigGuest()
|
||||
guest.ostype = 'hvm'
|
||||
guest.arch = 'itanic'
|
||||
guest.domtype = ['kvm']
|
||||
caps.guests.append(guest)
|
||||
|
||||
return caps
|
||||
|
||||
self.stub_out('nova.virt.libvirt.host.Host.get_capabilities',
|
||||
|
@ -5939,11 +5939,17 @@ class LibvirtDriver(driver.ComputeDriver):
|
||||
for dt in g.domtype:
|
||||
if dt != CONF.libvirt.virt_type:
|
||||
continue
|
||||
instance_cap = (
|
||||
fields.Architecture.canonicalize(g.arch),
|
||||
fields.HVType.canonicalize(dt),
|
||||
fields.VMMode.canonicalize(g.ostype))
|
||||
instance_caps.append(instance_cap)
|
||||
try:
|
||||
instance_cap = (
|
||||
fields.Architecture.canonicalize(g.arch),
|
||||
fields.HVType.canonicalize(dt),
|
||||
fields.VMMode.canonicalize(g.ostype))
|
||||
instance_caps.append(instance_cap)
|
||||
except exception.InvalidArchitectureName:
|
||||
# NOTE(danms): Libvirt is exposing a guest arch that nova
|
||||
# does not even know about. Avoid aborting here and
|
||||
# continue to process the rest.
|
||||
pass
|
||||
|
||||
return instance_caps
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user