From 23505ba77d76114cf8a0bf833f9a5bcd05bc1dd1 Mon Sep 17 00:00:00 2001 From: Angie Wang Date: Tue, 25 May 2021 18:49:21 -0400 Subject: [PATCH] Fix issue in partition data migration script The created partition dictonary partition_map is not an ordered dict so we need to sort it by its key - device node when iterating it to adjust the device nodes/paths for user created extra partitions to ensure the number of device node/path for each extra partition is calculated correctly, otherwise the adjustments could be messy that causes the partition DB update to fail. Tested AIO-SX upgrade with three additional partitions. Change-Id: I1cb3bbfaf144a59d29633c1784b0fde80529cd71 Closes-Bug: 1892554 Signed-off-by: Angie Wang --- .../upgrade-scripts/10-sysinv-adjust-partitions.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/controllerconfig/controllerconfig/upgrade-scripts/10-sysinv-adjust-partitions.py b/controllerconfig/controllerconfig/upgrade-scripts/10-sysinv-adjust-partitions.py index c7eaebed26..4c0019bf1d 100755 --- a/controllerconfig/controllerconfig/upgrade-scripts/10-sysinv-adjust-partitions.py +++ b/controllerconfig/controllerconfig/upgrade-scripts/10-sysinv-adjust-partitions.py @@ -375,7 +375,12 @@ def adjust_user_partitions(): increased_partition_number = \ installed_lvm_device['partition_number'] + 2 - for device, partition in six.iteritems(partition_map): + # partition_map is not an ordered dictionary, we + # need to sort partition_map by its key(device node) + # to ensure the adjustments for user created partitions + # are correct + for device, partition in sorted( + six.iteritems(partition_map)): # Adjust the device node/path of user created # partitions. The start/end/size of the partitions # will not be changed. @@ -401,7 +406,9 @@ def adjust_user_partitions(): update_db_pvs.append(pv) # Reverse the updating order. The partitions that - # moving backwards need to updated first. + # moving backwards need to updated first because of + # the UniqueConstraint "u_partition_path_host_id" + # for partition table update_db_partitions = update_db_partitions[::-1] else: # The primary LVM partition for cgts-vg in new release