Skip to content

Commit c9826ca

Browse files
SeanMooneystephenfin
authored andcommitted
Fix max cpu topologies with numa affinity
Nova has never supported specifying per numa node cpu toplogies. Logically the cpu toplogy of a guest is independent of its numa toplogy and there is no way to model different cpu toplogies per numa node or implement that in hardware. The presence of the code in nova that allowed the generation of these invalid configuration has now been removed as it broke the automatic selection of cpu topologies based on hw:max_[cpus|sockets|threads] flavor and image properties. This change removed the incorrect code and related unit tests with assert nova could generate invalid topologies. Closes-Bug: #1910466 Change-Id: Ia81a0fdbd950b51dbcc70c65ba492549a224ce2b (cherry picked from commit 387823b)
1 parent 5f994a1 commit c9826ca

File tree

6 files changed

+59
-306
lines changed

6 files changed

+59
-306
lines changed

nova/objects/instance_numa.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ def obj_make_compatible(self, primitive, target_version):
7979
'memory': obj_fields.IntegerField(),
8080
'pagesize': obj_fields.IntegerField(nullable=True,
8181
default=None),
82+
# TODO(sean-k-mooney): This is no longer used and should be
83+
# removed in v2
8284
'cpu_topology': obj_fields.ObjectField('VirtCPUTopology',
8385
nullable=True),
8486
'cpu_pinning_raw': obj_fields.DictOfIntegersField(nullable=True,

nova/tests/functional/libvirt/test_numa_servers.py

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -138,22 +138,16 @@ def test_create_server_with_numa_topology_and_cpu_topology_and_pinning(
138138
'hw:cpu_max_sockets': '2',
139139
'hw:cpu_max_cores': '2',
140140
'hw:cpu_max_threads': '8',
141-
'hw:cpu_policy': 'dedicated',
142-
'hw:mem_page_size': 'any'
143-
}
141+
'hw:cpu_policy': 'dedicated'}
144142
flavor_id = self._create_flavor(vcpu=8, extra_spec=extra_spec)
145-
self._run_build_test(flavor_id, end_status='ERROR')
143+
server = self._run_build_test(flavor_id)
146144

147-
# FIXME(sean-k-mooney): The instance should boot but
148-
# it fails due to https://bugs.launchpad.net/nova/+bug/1910466
149-
msg = "IndexError: list index out of range"
150-
self.assertIn(msg, self.stdlog.logger.output)
151-
# ctx = nova_context.get_admin_context()
152-
# inst = objects.Instance.get_by_uuid(ctx, server['id'])
153-
# self.assertEqual(2, len(inst.numa_topology.cells))
154-
# self.assertLessEqual(inst.vcpu_model.topology.sockets, 2)
155-
# self.assertLessEqual(inst.vcpu_model.topology.cores, 2)
156-
# self.assertLessEqual(inst.vcpu_model.topology.threads, 8)
145+
ctx = nova_context.get_admin_context()
146+
inst = objects.Instance.get_by_uuid(ctx, server['id'])
147+
self.assertEqual(2, len(inst.numa_topology.cells))
148+
self.assertLessEqual(inst.vcpu_model.topology.sockets, 2)
149+
self.assertLessEqual(inst.vcpu_model.topology.cores, 2)
150+
self.assertLessEqual(inst.vcpu_model.topology.threads, 8)
157151

158152
def test_create_server_with_numa_fails(self):
159153
"""Create a two NUMA node instance on a host with only one node.
@@ -252,7 +246,7 @@ def test_create_server_with_dedicated_policy(self):
252246

253247
inst = objects.Instance.get_by_uuid(self.ctxt, server['id'])
254248
self.assertEqual(1, len(inst.numa_topology.cells))
255-
self.assertEqual(5, inst.numa_topology.cells[0].cpu_topology.cores)
249+
self.assertEqual(5, inst.vcpu_model.topology.sockets)
256250

257251
def test_create_server_with_mixed_policy(self):
258252
"""Create a server using the 'hw:cpu_policy=mixed' extra spec.
@@ -302,7 +296,6 @@ def test_create_server_with_mixed_policy(self):
302296
# sanity check the instance topology
303297
inst = objects.Instance.get_by_uuid(self.ctxt, server['id'])
304298
self.assertEqual(1, len(inst.numa_topology.cells))
305-
self.assertEqual(4, inst.numa_topology.cells[0].cpu_topology.cores)
306299
self.assertEqual({0}, inst.numa_topology.cells[0].cpuset)
307300
self.assertEqual({1, 2, 3}, inst.numa_topology.cells[0].pcpuset)
308301
self.assertEqual(
@@ -511,8 +504,6 @@ def test_create_server_with_pcpu(self):
511504
ctx = nova_context.get_admin_context()
512505
inst = objects.Instance.get_by_uuid(ctx, server['id'])
513506
self.assertEqual(1, len(inst.numa_topology.cells))
514-
self.assertEqual(1, inst.numa_topology.cells[0].cpu_topology.cores)
515-
self.assertEqual(2, inst.numa_topology.cells[0].cpu_topology.threads)
516507

517508
def test_create_server_with_pcpu_fails(self):
518509
"""Create a pinned instance on a host with no PCPUs.

0 commit comments

Comments
 (0)