From 2ffc00c9d53f0b7b0c239fa65336d5f31f32bf57 Mon Sep 17 00:00:00 2001 From: Balazs Gibizer Date: Mon, 3 Feb 2025 11:07:34 +0100 Subject: [PATCH] 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 643a6a8a57945ceb1bf3c5971be2aeb3efd4fa72) (cherry picked from commit 7ff108b5fb91db31f2273eebeb60272e1c6e71b1) (cherry picked from commit f6be1131c29c5ef1a8410f893fc779d7245c4501) --- nova/objects/instance_numa.py | 11 ++++++++++- nova/tests/unit/objects/test_instance_numa.py | 7 ++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/nova/objects/instance_numa.py b/nova/objects/instance_numa.py index f112b08d535f..3a6d2e34763e 100644 --- a/nova/objects/instance_numa.py +++ b/nova/objects/instance_numa.py @@ -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 diff --git a/nova/tests/unit/objects/test_instance_numa.py b/nova/tests/unit/objects/test_instance_numa.py index c677fd09ca9d..c99431e56783 100644 --- a/nova/tests/unit/objects/test_instance_numa.py +++ b/nova/tests/unit/objects/test_instance_numa.py @@ -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(