Merge "Update InstanceNUMACell version after data migration" into stable/2023.2

This commit is contained in:
Zuul
2025-04-16 22:12:19 +00:00
committed by Gerrit Code Review
2 changed files with 12 additions and 6 deletions

View File

@@ -198,14 +198,23 @@ class InstanceNUMATopology(base.NovaObject,
for cell in obj.cells:
if len(cell.cpuset) == 0:
continue
# NOTE(gibi): This data migration populates the pcpuset field that
# is new in version 1.5. However below we bump the object version
# to 1.6 directly. This is intentional. The version 1.6 introduced
# a new possible value 'mixed' for the cpu_policy field. As that
# is a forward compatible change we don't have a specific data
# migration for it. But we also don't have an automated way to bump
# old object versions from 1.5 to 1.6. So we do it here just to
# avoid inconsistency between data and version in the DB.
if cell.cpu_policy == obj_fields.CPUAllocationPolicy.DEDICATED:
cell.pcpuset = cell.cpuset
cell.cpuset = set()
cell.VERSION = '1.6'
update_db = True
else:
if 'pcpuset' not in cell:
cell.pcpuset = set()
cell.VERSION = '1.6'
update_db = True
return update_db

View File

@@ -446,11 +446,8 @@ class _TestInstanceNUMATopology(object):
# pcpuset
self.assertEqual(set(), topo_loaded.cells[0].cpuset)
self.assertEqual({0, 1}, topo_loaded.cells[0].pcpuset)
# but the object version isn't bumped. So when the
# data is saved back to the DB it still has the old version 1.4, but
# also it has the new pcpuset field from version 1.6. This is bug
# https://bugs.launchpad.net/nova/+bug/2097359.
self.assertEqual('1.4', topo_loaded.cells[0].VERSION)
# and the version is bumped to 1.6
self.assertEqual('1.6', topo_loaded.cells[0].VERSION)
class TestInstanceNUMATopology(