Files
distcloud/distributedcloud/dcmanager/orchestrator/patch_orch_thread.py
Gustavo Herzmann bd7d2a6922 Refactor distributed cloud patch orchestration
Makes PatchOrchThread a subclass of the OrchThread, following the same
design used in the other types of orchestration. It also removes the
strategy step to orchestrate the system controller patching, as it
should be done separately, before initializing the patch orchestration
to patch the subclouds.

The alarm checks that were executed inside the 'updating' state are now
part of a new 'pre-check' state that runs at the beggining of the
orchestration process.

It also refactors the unit tests to be in line with the unit tests of
the other orchestrator types by using the TestSwUpdate base class.

Test Plan:
1. PASS - Verify successfull patch orchestration by applying and
          removing a NRR patch;
2. PASS - Verify successfull patch orchestration by applying and
          removing a RR patch;
3. PASS - Induce a management affecting alarm in a subcloud and verify
          that orchestration fails for that subcloud;
4. PASS - Induce a 900.001 alarm by partially apply a patch in a
          subcloud beforehand and verify that orchestration completes
          successfully for that subcloud;
5. PASS - Create a DC orch patch strategy, then manually patch a
          subcloud using the sw-manager patch-strategy command and
          then apply the DC orch patch strategy, verifying if the
          state machine skips from the 'creating VIM patch strategy'
          state directly to the 'finishing patch strategy' state;
6. PASS - Verify that no strategy step is created for the system
          controller;
7. PASS - Execute another orchestration type (e.g. prestage) and
          verify that it still works as expected.

Story: 2010584
Task: 47371

Co-Authored-By: Al Bailey <al.bailey@windriver.com>
Signed-off-by: Gustavo Herzmann <gustavo.herzmann@windriver.com>
Change-Id: I2c37bd59696e6f9e4fd706f3b3c97f8f9e4499b0
2023-02-27 09:48:14 -03:00

77 lines
2.8 KiB
Python

# Copyright 2017 Ericsson AB.
# Copyright (c) 2017-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.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from dccommon.drivers.openstack import vim
from dcmanager.common import consts
from dcmanager.orchestrator.orch_thread import OrchThread
from dcmanager.orchestrator.states.patch.applying_vim_patch_strategy import \
ApplyingVIMPatchStrategyState
from dcmanager.orchestrator.states.patch.creating_vim_patch_strategy import \
CreatingVIMPatchStrategyState
from dcmanager.orchestrator.states.patch.finishing_patch_strategy import \
FinishingPatchStrategyState
from dcmanager.orchestrator.states.patch.job_data import PatchJobData
from dcmanager.orchestrator.states.patch.pre_check import PreCheckState
from dcmanager.orchestrator.states.patch.updating_patches import \
UpdatingPatchesState
from oslo_log import log as logging
LOG = logging.getLogger(__name__)
class PatchOrchThread(OrchThread):
STATE_OPERATORS = {
consts.STRATEGY_STATE_PRE_CHECK:
PreCheckState,
consts.STRATEGY_STATE_UPDATING_PATCHES:
UpdatingPatchesState,
consts.STRATEGY_STATE_CREATING_VIM_PATCH_STRATEGY:
CreatingVIMPatchStrategyState,
consts.STRATEGY_STATE_APPLYING_VIM_PATCH_STRATEGY:
ApplyingVIMPatchStrategyState,
consts.STRATEGY_STATE_FINISHING_PATCH_STRATEGY:
FinishingPatchStrategyState,
}
def __init__(self, strategy_lock, audit_rpc_client):
super(PatchOrchThread, self).__init__(
strategy_lock,
audit_rpc_client,
consts.SW_UPDATE_TYPE_PATCH,
vim.STRATEGY_NAME_SW_PATCH,
starting_state=consts.STRATEGY_STATE_PRE_CHECK)
self.job_data = None
def pre_apply_setup(self):
super(PatchOrchThread, self).pre_apply_setup()
self.job_data = PatchJobData()
def post_delete_teardown(self):
super(PatchOrchThread, self).post_delete_teardown()
self.job_data = None
def determine_state_operator(self, strategy_step):
state = super(PatchOrchThread, self).determine_state_operator(
strategy_step)
# Share job data with the next state operator
state.set_job_data(self.job_data)
return state
def trigger_audit(self):
self.audit_rpc_client.trigger_patch_audit(self.context)