Skip to content

Commit 415b0e4

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Update InstanceNUMACell version after data migration" into unmaintained/2023.1
2 parents b597517 + 7bb6b8d commit 415b0e4

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

nova/objects/instance_numa.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,23 @@ def _migrate_legacy_dedicated_instance_cpuset(cls, obj):
198198
for cell in obj.cells:
199199
if len(cell.cpuset) == 0:
200200
continue
201-
201+
# NOTE(gibi): This data migration populates the pcpuset field that
202+
# is new in version 1.5. However below we bump the object version
203+
# to 1.6 directly. This is intentional. The version 1.6 introduced
204+
# a new possible value 'mixed' for the cpu_policy field. As that
205+
# is a forward compatible change we don't have a specific data
206+
# migration for it. But we also don't have an automated way to bump
207+
# old object versions from 1.5 to 1.6. So we do it here just to
208+
# avoid inconsistency between data and version in the DB.
202209
if cell.cpu_policy == obj_fields.CPUAllocationPolicy.DEDICATED:
203210
cell.pcpuset = cell.cpuset
204211
cell.cpuset = set()
212+
cell.VERSION = '1.6'
205213
update_db = True
206214
else:
207215
if 'pcpuset' not in cell:
208216
cell.pcpuset = set()
217+
cell.VERSION = '1.6'
209218
update_db = True
210219

211220
return update_db

nova/tests/unit/objects/test_instance_numa.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -446,11 +446,8 @@ def test__migrate_legacy_dedicated_instance_cpuset(self):
446446
# pcpuset
447447
self.assertEqual(set(), topo_loaded.cells[0].cpuset)
448448
self.assertEqual({0, 1}, topo_loaded.cells[0].pcpuset)
449-
# but the object version isn't bumped. So when the
450-
# data is saved back to the DB it still has the old version 1.4, but
451-
# also it has the new pcpuset field from version 1.6. This is bug
452-
# https://bugs.launchpad.net/nova/+bug/2097359.
453-
self.assertEqual('1.4', topo_loaded.cells[0].VERSION)
449+
# and the version is bumped to 1.6
450+
self.assertEqual('1.6', topo_loaded.cells[0].VERSION)
454451

455452

456453
class TestInstanceNUMATopology(

0 commit comments

Comments
 (0)