Skip to content

Commit 6ee394f

Browse files
SeanMooneygibizer
authored andcommitted
repoduce post liberty pre vicoria instance numa db issue
This change reproduces a bug in the db load of old instance numa toplogy json blobs in _migrate_legacy_dedicated_instance_cpuset that failed to account for defaulting pcpuset to the empty set when it is not in the json blob. Related-Bug: #2080556 Change-Id: Ia0f327c501f65786d5b2538b2742ec2786486956 (cherry picked from commit 521db4a) (cherry picked from commit c00b76b) (cherry picked from commit 7ae3afe)
1 parent b834c62 commit 6ee394f

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

nova/objects/instance_numa.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,11 @@ def _migrate_legacy_dedicated_instance_cpuset(cls, obj):
192192
continue
193193

194194
if cell.cpu_policy != obj_fields.CPUAllocationPolicy.DEDICATED:
195+
# FIXME(sean-k-mooney): we should be setting the pcpuset
196+
# to an empty set here
197+
# if not 'pcpuset' in cell:
198+
# cell.pcpuset = set()
199+
# update_db = True
195200
continue
196201

197202
cell.pcpuset = cell.cpuset

nova/tests/unit/objects/test_instance_numa.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,51 @@ def test_obj_from_db_obj(self):
372372
self.assertEqual(set(), obj_cell.cpuset)
373373
self.assertEqual(topo_cell.cpuset, obj_cell.pcpuset)
374374

375+
def test_obj_from_db_obj_no_pinning(self):
376+
"""Test of creating 'InstanceNUMATopology' OVO object from the
377+
database primitives, which has an old version 'InstanceNUMACell'
378+
primitives.
379+
380+
Prior to version 1.5, 'InstanceNUMACell' saves the instance CPUs in
381+
the 'cpuset' field, for both the pinned CPUs of a dedicated and the
382+
un-pinned CPUs of a shared instances, after version 1.5, any pinned
383+
CPUs of dedicated instance are moved to 'pcpuset'. this test verifies
384+
the CPU movement for instance with a 'dedicated' allocation policy.
385+
386+
This test is for the case where the instance has no pinned CPUs but
387+
the instance has a numa topology such as when hugepages are used.
388+
See bug: https://bugs.launchpad.net/nova/+bug/2080556 for more details.
389+
"""
390+
fake_topo_obj_w_cell_v1_4 = objects.InstanceNUMATopology(
391+
instance_uuid=fake_instance_uuid,
392+
cells=[
393+
objects.InstanceNUMACell(
394+
id=0, cpuset=set([1, 2]), memory=512,
395+
pagesize=2048),
396+
objects.InstanceNUMACell(
397+
id=1, cpuset=set([3, 4]), memory=512,
398+
pagesize=2048),
399+
])
400+
401+
fake_topo_obj = copy.deepcopy(fake_topo_obj_w_cell_v1_4)
402+
for cell in fake_topo_obj.cells:
403+
cell.cpu_policy = objects.fields.CPUAllocationPolicy.SHARED
404+
405+
numa_topology = objects.InstanceNUMATopology.obj_from_db_obj(
406+
self.context, fake_instance_uuid, fake_topo_obj._to_json())
407+
408+
for obj_cell, topo_cell in zip(
409+
numa_topology.cells,
410+
fake_topo_obj_w_cell_v1_4['cells']):
411+
self.assertEqual(topo_cell.cpuset, obj_cell.cpuset)
412+
# 'pcpuset' should be an empty set however
413+
# obj_from_db_obj() or more specifically
414+
# _migrate_legacy_dedicated_instance_cpuset() does not set
415+
# 'pcpuset' to an empty set when it is not in the json data.
416+
# self.assertEqual(set(), obj_cell.pcpuset)
417+
self.assertRaises(
418+
NotImplementedError, getattr, obj_cell, 'pcpuset')
419+
375420

376421
class TestInstanceNUMATopology(
377422
test_objects._LocalTest, _TestInstanceNUMATopology,

0 commit comments

Comments
 (0)