Test numa and vcpu topologies bug: #1910466

This change reproduces bug #1910466
When hw:cpu_max_[sockets|cores|threads] is configured
in addition to an explict numa topologies and cpu pinning
nova is currently incapable of generating the correct
virtual CPU topology resulting in an index out of range
error as we attempt to retrieve the first topology
from an empty list.

This change reproduces the error via a new functional
test.

Related-Bug: #1910466
Change-Id: I333b3d85deed971678141307dd06545e308cf989
(cherry picked from commit fe25fa13e0)
This commit is contained in:
Sean Mooney 2021-01-06 18:56:39 +00:00 committed by Stephen Finucane
parent 97c3517e7e
commit 5f994a18b3
1 changed files with 37 additions and 2 deletions

View File

@ -104,8 +104,8 @@ class NUMAServersTest(NUMAServersTestBase):
nodes.
"""
host_info = fakelibvirt.HostInfo(cpu_nodes=2, cpu_sockets=1,
cpu_cores=2, cpu_threads=2)
host_info = fakelibvirt.HostInfo(
cpu_nodes=2, cpu_sockets=1, cpu_cores=2, cpu_threads=2)
self.start_compute(host_info=host_info, hostname='compute1')
extra_spec = {'hw:numa_nodes': '2'}
@ -120,6 +120,41 @@ class NUMAServersTest(NUMAServersTestBase):
self.assertNotIn('cpu_topology', inst.numa_topology.cells[0])
self.assertNotIn('cpu_topology', inst.numa_topology.cells[1])
def test_create_server_with_numa_topology_and_cpu_topology_and_pinning(
self):
"""Create a server with two NUMA nodes.
This should pass and result in a guest NUMA topology with two NUMA
nodes, pinned cpus and numa affined memory.
"""
host_info = fakelibvirt.HostInfo(
cpu_nodes=2, cpu_sockets=1, cpu_cores=4, cpu_threads=1,
kB_mem=(1024 * 1024 * 16)) # 16 GB
self.start_compute(host_info=host_info, hostname='compute1')
extra_spec = {
'hw:numa_nodes': '2',
'hw:cpu_max_sockets': '2',
'hw:cpu_max_cores': '2',
'hw:cpu_max_threads': '8',
'hw:cpu_policy': 'dedicated',
'hw:mem_page_size': 'any'
}
flavor_id = self._create_flavor(vcpu=8, extra_spec=extra_spec)
self._run_build_test(flavor_id, end_status='ERROR')
# FIXME(sean-k-mooney): The instance should boot but
# it fails due to https://bugs.launchpad.net/nova/+bug/1910466
msg = "IndexError: list index out of range"
self.assertIn(msg, self.stdlog.logger.output)
# ctx = nova_context.get_admin_context()
# inst = objects.Instance.get_by_uuid(ctx, server['id'])
# self.assertEqual(2, len(inst.numa_topology.cells))
# self.assertLessEqual(inst.vcpu_model.topology.sockets, 2)
# self.assertLessEqual(inst.vcpu_model.topology.cores, 2)
# self.assertLessEqual(inst.vcpu_model.topology.threads, 8)
def test_create_server_with_numa_fails(self):
"""Create a two NUMA node instance on a host with only one node.