Skip to content

Commit 7bb6b8d

Browse files
committed
Update InstanceNUMACell version after data migration
The data migration of InstanceNUMACell 1.4 to 1.5 only moved the data to the new pcpuset field but does not update the ovo version string of the object in the DB. This resulted in an 1.6 data with an 1.4 version string in the DB which subsequently causes that an old compute running 1.4 ovo version will think it got an old ovo even though the data is already in the new format. This leads to instance lifecycle errors and if the nova-compute saves the instance then it also leads to permanent data loss. So this change modified the data migration to also update the ovo version in the DB so that the version string in the DB matches the schema the data uses in the DB. Related-Bug: #2097359 Change-Id: I9a99f10526f8e466ac04b035121b24be70a23dae (cherry picked from commit 643a6a8) (cherry picked from commit 7ff108b) (cherry picked from commit f6be113) (cherry picked from commit 2ffc00c)
1 parent d907c1f commit 7bb6b8d

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)