Merge "Fix deploy host status update when install fails"
This commit is contained in:
commit
337d2fb3f9
|
@ -110,11 +110,11 @@ class SoftwareAPI:
|
|||
def begin_update(self):
|
||||
tid = threading.get_native_id()
|
||||
msg = f"{tid} is to acquire lock."
|
||||
LOG.info(msg)
|
||||
LOG.debug(msg)
|
||||
SoftwareAPI._lock.acquire()
|
||||
|
||||
def end_update(self):
|
||||
SoftwareAPI._lock.release()
|
||||
tid = threading.get_native_id()
|
||||
msg = f"{tid} released lock."
|
||||
LOG.info(msg)
|
||||
LOG.debug(msg)
|
||||
|
|
|
@ -581,16 +581,10 @@ class PatchMessageAgentInstallResp(messages.PatchMessage):
|
|||
sc.hosts_lock.release()
|
||||
|
||||
deploy_host_state = DeployHostState(hostname)
|
||||
# NOTE(bqian) apparently it uses 2 boolean to indicate 2 situations
|
||||
# where there could be 4 combinations
|
||||
if self.status:
|
||||
deploy_host_state.deployed()
|
||||
return
|
||||
elif self.reject_reason:
|
||||
else:
|
||||
deploy_host_state.deploy_failed()
|
||||
return
|
||||
|
||||
LOG.error("Bug: shouldn't reach here")
|
||||
|
||||
def send(self, sock): # pylint: disable=unused-argument
|
||||
LOG.error("Should not get here")
|
||||
|
@ -1346,7 +1340,7 @@ class PatchController(PatchService):
|
|||
|
||||
# Get the release_id from the patch's metadata
|
||||
# and check to see if it's already uploaded
|
||||
release_id = get_release_from_patch(patch_file,'id')
|
||||
release_id = get_release_from_patch(patch_file, 'id')
|
||||
|
||||
release = self.release_collection.get_release_by_id(release_id)
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ from software.software_controller import PatchMessageQueryDetailedResp
|
|||
from software.software_controller import PatchMessageAgentInstallReq
|
||||
from software.software_controller import PatchMessageAgentInstallResp
|
||||
from software.software_controller import PatchMessageDropHostReq
|
||||
|
||||
from software.states import DEPLOY_HOST_STATES
|
||||
|
||||
FAKE_AGENT_ADDRESS = "127.0.0.1"
|
||||
FAKE_AGENT_MCAST_GROUP = "239.1.1.4"
|
||||
|
@ -35,7 +35,7 @@ class FakeSoftwareController(object):
|
|||
self.allow_insvc_softwareing = True
|
||||
self.controller_address = FAKE_CONTROLLER_ADDRESS
|
||||
self.controller_neighbours = {}
|
||||
self.hosts = {}
|
||||
self.hosts = {FAKE_HOST_IP: {"hostname": "controller-0"}}
|
||||
self.interim_state = {}
|
||||
self.latest_feed_commit = FAKE_OSTREE_FEED_COMMIT
|
||||
self.patch_op_counter = 0
|
||||
|
@ -143,12 +143,16 @@ class SoftwareControllerMessagesTestCase(testtools.TestCase):
|
|||
mock_sock.sendall.assert_called()
|
||||
|
||||
@mock.patch('software.software_controller.sc', FakeSoftwareController())
|
||||
def test_message_class_handle(self):
|
||||
@mock.patch('software.db.api.SoftwareAPI.get_deploy_host_by_hostname',
|
||||
return_value={"state": DEPLOY_HOST_STATES.DEPLOYING})
|
||||
@mock.patch('software.software_entities.DeployHostHandler.update', return_value=True)
|
||||
def test_message_class_handle(self, mock_get_deploy_host_by_hostname, mock_update): # pylint: disable=unused-argument
|
||||
"""'handle' method tests"""
|
||||
addr = [FAKE_CONTROLLER_ADDRESS, ] # addr is a list
|
||||
mock_sock = mock.Mock()
|
||||
special_setup = {
|
||||
PatchMessageDropHostReq: ('ip', FAKE_HOST_IP),
|
||||
PatchMessageAgentInstallResp: ('status', True),
|
||||
}
|
||||
|
||||
for message_class in SoftwareControllerMessagesTestCase.message_classes:
|
||||
|
|
Loading…
Reference in New Issue