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
(cherry picked from commit 71df650d0a
)
This commit is contained in:
parent
9c6d900486
commit
2b86a9cacc
@ -16157,6 +16157,14 @@ class LibvirtConnTestCase(test.NoDBTestCase,
|
|||||||
guest.domtype = ['kvm']
|
guest.domtype = ['kvm']
|
||||||
caps.guests.append(guest)
|
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
|
return caps
|
||||||
|
|
||||||
self.stubs.Set(host.Host, "get_capabilities",
|
self.stubs.Set(host.Host, "get_capabilities",
|
||||||
|
@ -5861,11 +5861,17 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||||||
for dt in g.domtype:
|
for dt in g.domtype:
|
||||||
if dt != CONF.libvirt.virt_type:
|
if dt != CONF.libvirt.virt_type:
|
||||||
continue
|
continue
|
||||||
|
try:
|
||||||
instance_cap = (
|
instance_cap = (
|
||||||
fields.Architecture.canonicalize(g.arch),
|
fields.Architecture.canonicalize(g.arch),
|
||||||
fields.HVType.canonicalize(dt),
|
fields.HVType.canonicalize(dt),
|
||||||
fields.VMMode.canonicalize(g.ostype))
|
fields.VMMode.canonicalize(g.ostype))
|
||||||
instance_caps.append(instance_cap)
|
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
|
return instance_caps
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user