Fix: Retain sysinv data during migration

The migration code was deleting /opt/platform/<FROM_RELEASE>/sysinv,
before it was migrated to /opt/platform/<TO_RELEASE>/sysinv.
This caused the files inside like `sysinv.conf.default` to be lost
during simplex upgrade.

Originally, in legacy restore, `sysinv.conf.default` was
individually restored after migration so the deletion
had no impact.

`sysinv.conf.default` is required on non-SX systems.
This is used so that other hosts sysinv-agent can mount and
have an initial sysinv.conf suitable for RPC to the controller.

The loss of the file is not problematic on a SX system, but would
prevent a later SX-to-DX migration.

TEST PLAN
PASS: Optimized upgrade AIO-SX, stx6 to stx8
PASS: Optimized upgrade AIO-SX, stx7 to stx8

Closes-bug: 2042971
Signed-off-by: Joshua Kraitberg <joshua.kraitberg@windriver.com>
Change-Id: I7a22e050f74785b99ea6b7758cf23d3419add1de
This commit is contained in:
Joshua Kraitberg 2023-11-09 12:46:50 -05:00
parent ab82680c1d
commit d9e12f6c45
1 changed files with 7 additions and 2 deletions

View File

@ -1239,16 +1239,21 @@ def extract_data_from_archive(archive, staging_dir, from_release, to_release):
stat.S_IROTH | stat.S_IXOTH
shutil.rmtree(from_puppet_path, ignore_errors=True)
shutil.rmtree(from_sysinv_path, ignore_errors=True)
shutil.rmtree(from_keyring_path, ignore_errors=True)
shutil.rmtree(
os.path.join(PLATFORM_PATH, "config", to_release, "pxelinux.cfg"),
ignore_errors=True)
os.makedirs(from_puppet_path, dir_options)
os.makedirs(from_sysinv_path, dir_options)
os.makedirs(from_keyring_path, dir_options)
# During legacy upgrade the from_sysinv_path directory should be recreated.
# During optimized upgrade, the from_sysinv_path is already prepared.
# The only from_release that supports legacy upgrade is 22.06.
if from_release == "22.06":
shutil.rmtree(from_sysinv_path, ignore_errors=True)
os.makedirs(from_sysinv_path, dir_options)
extract_relative_directory(archive, from_puppet_path, from_puppet_path)
extract_relative_directory(archive, from_keyring_path, from_keyring_path)
extract_relative_directory(archive, from_pxelinux_path, from_pxelinux_path)