Merge "Skip prestage_prepare for upgrade on Debian"
This commit is contained in:
commit
53f9222455
@ -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)
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user