Add unlock validations for deploy complete and activate

After deploy host with the host locked the software
deploy activate can be executed, which is incorrect.
This commit fix this by adding validations to check
if all hosts are unlocked and online.

Test Plan:
PASS: Block to run deploy activate after deploy host
before unlock the host.

Story: 2010676
Task: 50583

Change-Id: I3a2d875904c163dfc224b0679eb8ae4f557bfdae
Signed-off-by: Luis Eduardo Bonatti <LuizEduardo.Bonatti@windriver.com>
This commit is contained in:
Luis Eduardo Bonatti
2024-07-09 21:57:41 -03:00
parent d23410db11
commit ab495e481f
3 changed files with 15 additions and 0 deletions

View File

@@ -129,6 +129,7 @@ WORKER = 'worker'
AVAILABILITY_ONLINE = 'online'
ADMIN_LOCKED = 'locked'
ADMIN_UNLOCKED = 'unlocked'
SOFTWARE_ALARMS = {
fm_constants.FM_ALARM_ID_USM_DEPLOY_HOST_SUCCESS_RR: {

View File

@@ -88,6 +88,7 @@ import software.utils as utils
from software.sysinv_utils import get_k8s_ver
from software.sysinv_utils import is_system_controller
from software.sysinv_utils import update_host_sw_version
from software.sysinv_utils import are_all_hosts_unlocked_and_online
from software.db.api import get_instance
@@ -2971,6 +2972,10 @@ class PatchController(PatchService):
return dict(info=msg_info, warning=msg_warning, error=msg_error)
def _deploy_complete(self):
if not are_all_hosts_unlocked_and_online():
msg = f"Hosts must be {constants.ADMIN_UNLOCKED} and {constants.AVAILABILITY_ONLINE}."
raise SoftwareServiceError(error=msg)
is_all_hosts_in_deployed_state = all(host_state.get("state") == DEPLOY_HOST_STATES.DEPLOYED.value
for host_state in self.db_api_instance.get_deploy_host())
if not is_all_hosts_in_deployed_state:
@@ -3035,6 +3040,9 @@ class PatchController(PatchService):
return True
def _check_pre_activate(self):
if not are_all_hosts_unlocked_and_online():
msg = f"Hosts must be {constants.ADMIN_UNLOCKED} and {constants.AVAILABILITY_ONLINE}."
raise SoftwareServiceError(error=msg)
# check current deployment, deploy to all hosts have completed,
# the deploy state is host-done, or
# activate-failed' as reattempt from a previous failed activate

View File

@@ -61,6 +61,12 @@ def is_host_locked_and_online(host):
return True
return False
def are_all_hosts_unlocked_and_online():
for ihost in get_ihost_list():
if ihost.administrative != constants.ADMIN_UNLOCKED or ihost.availability != constants.AVAILABILITY_ONLINE:
return False
return True
def get_system_info():
"""Returns system type and system mode"""