Skip prestage_prepare for upgrade on Debian

Since the ostree repo will no longer be copied to /var/run before
prestaging for upgrade, preparing the prestage packages is not
required anymore.

This commit removes support for preparing prestage packages for
upgrade in dcmanager.

Since the existing unit test for this support is no longer
relevant, it has been removed.

Test Plan:
PASS: Verify that prestage for upgrade is successfully executed.

PASS: Verify that prestage for reinstall is successfully executed.

Depends-On: https://review.opendev.org/c/starlingx/ansible-playbooks/+/870682
Closes-Bug: 2003271
Change-Id: Ibc4f1a3969db060f708592dbedd91a1f3fdbd6fa
Signed-off-by: Shrikumar Sharma <shrikumar.sharma@windriver.com>
This commit is contained in:
Shrikumar Sharma 2023-01-31 01:58:40 +00:00
parent ae7d2f33ea
commit 5fb5052427
2 changed files with 51 additions and 9 deletions

View File

@ -1,4 +1,4 @@
# Copyright (c) 2022 Wind River Systems, Inc.
# Copyright (c) 2023 Wind River Systems, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -58,6 +58,8 @@ ANSIBLE_PRESTAGE_SUBCLOUD_IMAGES_PLAYBOOK = \
"/usr/share/ansible/stx-ansible/playbooks/prestage_images.yml"
ANSIBLE_PRESTAGE_INVENTORY_SUFFIX = '_prestage_inventory.yml'
LAST_SW_VERSION_IN_CENTOS = "22.06"
def is_deploy_status_prestage(deploy_status):
return deploy_status in (consts.PRESTAGE_STATE_PREPARE,
@ -315,9 +317,18 @@ def _sync_run_prestage_prepare_packages(context, subcloud, payload):
LOG.info("Prepare prestage ansible successful")
# TODO(Shrikumar): Cleanup this function, especially the comparison for
# software versions.
# Rationale: In CentOS, prestage_prepare is required; in Debian, it is not.
@utils.synchronized('prestage-prepare-packages', external=True)
def prestage_prepare(context, subcloud, payload):
"""Run the prepare prestage packages playbook if required."""
if SW_VERSION > LAST_SW_VERSION_IN_CENTOS:
LOG.info("Skipping prestage package preparation in Debian")
return
if is_upgrade(subcloud.software_version):
if not os.path.exists(PRESTAGE_PREPARATION_COMPLETED_FILE):
_sync_run_prestage_prepare_packages(context, subcloud, payload)

View File

@ -39,6 +39,8 @@ from dcmanager.tests.unit.common import fake_subcloud
from dcmanager.tests import utils
from tsconfig.tsconfig import SW_VERSION
LAST_SW_VERSION_IN_CENTOS = "22.06"
FAKE_ADMIN_USER_ID = 1
FAKE_SYSINV_USER_ID = 2
@ -2067,20 +2069,20 @@ class TestSubcloudManager(base.DCManagerTestCase):
@mock.patch.object(prestage, 'prestage_packages')
@mock.patch.object(cutils, 'delete_subcloud_inventory')
@mock.patch.object(prestage, '_run_ansible')
def test_prestage_subcloud_prestage_prepare(self,
mock_run_ansible,
mock_delete_subcloud_inventory,
mock_prestage_packages,
mock_prestage_images,
mock_prestage_complete):
def test_prestage_subcloud_prestage_prepare_centos(self,
mock_run_ansible,
mock_delete_subcloud_inventory,
mock_prestage_packages,
mock_prestage_images,
mock_prestage_complete):
values = copy.copy(FAKE_PRESTAGE_PAYLOAD)
subcloud = self.create_subcloud_static(self.ctx,
name='subcloud1',
deploy_status=consts.DEPLOY_STATE_NONE)
current_sw_version = prestage.SW_VERSION
prestage.SW_VERSION = LAST_SW_VERSION_IN_CENTOS
prestage._prestage_standalone_thread(self.ctx, subcloud, payload=values)
mock_run_ansible.return_value = None
mock_prestage_packages.assert_called_once_with(self.ctx, subcloud, values)
mock_prestage_images.assert_called_once_with(self.ctx, subcloud, values)
@ -2089,9 +2091,38 @@ class TestSubcloudManager(base.DCManagerTestCase):
# Verify that subcloud has the correct deploy status
updated_subcloud = db_api.subcloud_get_by_name(self.ctx, subcloud.name)
prestage.SW_VERSION = current_sw_version
self.assertEqual(consts.PRESTAGE_STATE_PREPARE,
updated_subcloud.deploy_status)
@mock.patch.object(prestage, 'prestage_complete')
@mock.patch.object(prestage, 'prestage_images')
@mock.patch.object(prestage, 'prestage_packages')
@mock.patch.object(cutils, 'delete_subcloud_inventory')
@mock.patch.object(prestage, '_run_ansible')
def test_prestage_subcloud_prestage_prepare_debian(self,
mock_run_ansible,
mock_delete_subcloud_inventory,
mock_prestage_packages,
mock_prestage_images,
mock_prestage_complete):
values = copy.copy(FAKE_PRESTAGE_PAYLOAD)
subcloud = self.create_subcloud_static(self.ctx,
name='subcloud1',
deploy_status=consts.DEPLOY_STATE_NONE)
prestage._prestage_standalone_thread(self.ctx, subcloud, payload=values)
mock_run_ansible.return_value = None
mock_prestage_packages.assert_called_once_with(self.ctx, subcloud, values)
mock_prestage_images.assert_called_once_with(self.ctx, subcloud, values)
mock_prestage_complete.assert_called_once_with(self.ctx, subcloud.id)
mock_delete_subcloud_inventory.return_value = None
# Verify that subcloud has the correct deploy status
updated_subcloud = db_api.subcloud_get_by_name(self.ctx, subcloud.name)
self.assertEqual(consts.DEPLOY_STATE_NONE,
updated_subcloud.deploy_status)
def test_get_cached_regionone_data(self):
mock_keystone_client = FakeKeystoneClient()
mock_sysinv_client = FakeSysinvClient()