Remove incorrect host validation from deploy host
Now with the state machine introduced by commit [1], the host state validation once done by [2] is not needed anymore, and in fact was incorrectly blocking the "deploy host" command from being reentrant. This commit fixes this issue. [1] https://review.opendev.org/c/starlingx/update/+/914929 [2] https://review.opendev.org/c/starlingx/update/+/914825 Test Plan PASS: force "deploy host" to fail, then once the host is in "failed" state, run deploy "host again" and verify the system does not block it from proceeding Story: 2010676 Task: 49938 Change-Id: I0d2a8a4ab9ea98f83fbd7253cf4f174a257ee070 Signed-off-by: Heitor Matsui <heitorvieira.matsui@windriver.com>
This commit is contained in:
parent
c5a7d1d336
commit
70fc598dae
|
@ -1337,25 +1337,9 @@ def set_host_target_load(hostname, major_release):
|
|||
raise
|
||||
|
||||
|
||||
def validate_host_state_to_deploy_host(hostname):
|
||||
"""
|
||||
Check if the deployment host state for the hostname is pending.
|
||||
|
||||
If the validation fails raise SoftwareServiceError exception.
|
||||
|
||||
:param hostname: Hostname of the host to be deployed
|
||||
"""
|
||||
|
||||
host_state = get_instance().get_deploy_host_by_hostname(hostname).get("state")
|
||||
if host_state != states.DEPLOY_HOST_STATES.PENDING.value:
|
||||
msg = (f"Host state is {host_state} and should be "
|
||||
f"{states.DEPLOY_HOST_STATES.PENDING.value}")
|
||||
raise SoftwareServiceError(msg)
|
||||
|
||||
def deploy_host_validations(hostname):
|
||||
"""
|
||||
Check the conditions below:
|
||||
Host state is pending.
|
||||
If system mode is duplex, check if provided hostname satisfy the right deployment order.
|
||||
Host is locked and online.
|
||||
|
||||
|
@ -1364,7 +1348,6 @@ def deploy_host_validations(hostname):
|
|||
|
||||
:param hostname: Hostname of the host to be deployed
|
||||
"""
|
||||
validate_host_state_to_deploy_host(hostname)
|
||||
_, system_mode = get_system_info()
|
||||
simplex = (system_mode == constants.SYSTEM_MODE_SIMPLEX)
|
||||
if simplex:
|
||||
|
|
|
@ -4,14 +4,9 @@
|
|||
# Copyright (c) 2024 Wind River Systems, Inc.
|
||||
#
|
||||
import unittest
|
||||
from unittest.mock import MagicMock
|
||||
from unittest.mock import patch
|
||||
|
||||
from software import states
|
||||
from software.exceptions import SoftwareServiceError
|
||||
from software.release_data import SWReleaseCollection
|
||||
from software.software_functions import ReleaseData
|
||||
from software.software_functions import validate_host_state_to_deploy_host
|
||||
|
||||
metadata = """<?xml version="1.0" ?>
|
||||
<patch>
|
||||
|
@ -191,17 +186,3 @@ class TestSoftwareFunction(unittest.TestCase):
|
|||
self.assertEqual(val["restart_script"], r.restart_script)
|
||||
self.assertEqual(val["commit_id"], r.commit_id)
|
||||
self.assertEqual(val["checksum"], r.commit_checksum)
|
||||
|
||||
|
||||
@patch('software.db.api.SoftwareAPI')
|
||||
def test_validate_host_state_to_deploy_host_raises_exception_if_deploy_host_state_is_wrong(self, software_api_mock):
|
||||
# Arrange
|
||||
deploy_host_state = states.DEPLOY_HOST_STATES.DEPLOYED.value
|
||||
deploy_by_hostname = MagicMock(return_value={"state": deploy_host_state})
|
||||
software_api_mock.return_value = MagicMock(get_deploy_host_by_hostname=deploy_by_hostname)
|
||||
with self.assertRaises(SoftwareServiceError) as error:
|
||||
# Actions
|
||||
validate_host_state_to_deploy_host(hostname="abc")
|
||||
# Assertions
|
||||
error_msg = "Host state is deployed and should be pending"
|
||||
self.assertEqual(str(error.exception), error_msg)
|
||||
|
|
Loading…
Reference in New Issue