overcloud status report the correct cd for the given plan
Choose the most recent execution with the correct plan_name in the input field. Also push the filtering/ordering up to the mistral REST API where possible. Change-Id: I12c28237053bcbd52b60f2abda2194fd7d80c2b5 Closes-bug: #1895824
This commit is contained in:
parent
974b967531
commit
9be4f9cb4d
|
@ -450,14 +450,17 @@ class DeploymentStatusAction(base.TripleOAction):
|
||||||
# Will get set to new status if an update is required
|
# Will get set to new status if an update is required
|
||||||
status_update = None
|
status_update = None
|
||||||
|
|
||||||
cd_execs = workflow_client.executions.find(
|
for cd_exec in workflow_client.executions.list(
|
||||||
workflow_name='tripleo.deployment.v1.config_download_deploy')
|
sort_keys="updated_at",
|
||||||
cd_execs.sort(key=lambda x: x.updated_at)
|
sort_dirs="desc",
|
||||||
if cd_execs:
|
fields=['input', 'output', 'state'],
|
||||||
cd_exec = workflow_client.executions.get(cd_execs[-1].id)
|
workflow_name='tripleo.deployment.v1.config_download_deploy'
|
||||||
|
):
|
||||||
|
if json.loads(cd_exec.input).get('plan_name') == self.plan:
|
||||||
cd_status = cd_exec.state
|
cd_status = cd_exec.state
|
||||||
ansible_status = json.loads(
|
ansible_status = json.loads(
|
||||||
cd_exec.output).get('deployment_status')
|
cd_exec.output).get('deployment_status')
|
||||||
|
break
|
||||||
|
|
||||||
def update_status(status):
|
def update_status(status):
|
||||||
# If we need to update the status return it
|
# If we need to update the status return it
|
||||||
|
|
|
@ -751,8 +751,9 @@ class DeploymentStatusActionTest(base.TestCase):
|
||||||
execution.updated_at = 1
|
execution.updated_at = 1
|
||||||
execution.state = 'SUCCESS'
|
execution.state = 'SUCCESS'
|
||||||
execution.output = '{"deployment_status":"DEPLOY_SUCCESS"}'
|
execution.output = '{"deployment_status":"DEPLOY_SUCCESS"}'
|
||||||
|
execution.input = '{"plan_name":"overcloud"}'
|
||||||
mistral().executions.get.return_value = execution
|
mistral().executions.get.return_value = execution
|
||||||
mistral().executions.find.return_value = [execution]
|
mistral().executions.list.return_value = [execution]
|
||||||
|
|
||||||
action = deployment.DeploymentStatusAction(self.plan)
|
action = deployment.DeploymentStatusAction(self.plan)
|
||||||
result = action.run(self.ctx)
|
result = action.run(self.ctx)
|
||||||
|
@ -782,8 +783,9 @@ class DeploymentStatusActionTest(base.TestCase):
|
||||||
execution.updated_at = 1
|
execution.updated_at = 1
|
||||||
execution.state = 'SUCCESS'
|
execution.state = 'SUCCESS'
|
||||||
execution.output = '{"deployment_status":"DEPLOY_SUCCESS"}'
|
execution.output = '{"deployment_status":"DEPLOY_SUCCESS"}'
|
||||||
|
execution.input = '{"plan_name":"overcloud"}'
|
||||||
mistral().executions.get.return_value = execution
|
mistral().executions.get.return_value = execution
|
||||||
mistral().executions.find.return_value = [execution]
|
mistral().executions.list.return_value = [execution]
|
||||||
|
|
||||||
action = deployment.DeploymentStatusAction(self.plan)
|
action = deployment.DeploymentStatusAction(self.plan)
|
||||||
result = action.run(self.ctx)
|
result = action.run(self.ctx)
|
||||||
|
@ -813,8 +815,9 @@ class DeploymentStatusActionTest(base.TestCase):
|
||||||
execution.updated_at = 1
|
execution.updated_at = 1
|
||||||
execution.state = 'SUCCESS'
|
execution.state = 'SUCCESS'
|
||||||
execution.output = '{"deployment_status":"DEPLOY_SUCCESS"}'
|
execution.output = '{"deployment_status":"DEPLOY_SUCCESS"}'
|
||||||
|
execution.input = '{"plan_name":"overcloud"}'
|
||||||
mistral().executions.get.return_value = execution
|
mistral().executions.get.return_value = execution
|
||||||
mistral().executions.find.return_value = [execution]
|
mistral().executions.list.return_value = [execution]
|
||||||
|
|
||||||
action = deployment.DeploymentStatusAction(self.plan)
|
action = deployment.DeploymentStatusAction(self.plan)
|
||||||
result = action.run(self.ctx)
|
result = action.run(self.ctx)
|
||||||
|
@ -844,8 +847,9 @@ class DeploymentStatusActionTest(base.TestCase):
|
||||||
execution.updated_at = 1
|
execution.updated_at = 1
|
||||||
execution.state = 'SUCCESS'
|
execution.state = 'SUCCESS'
|
||||||
execution.output = '{"deployment_status":"DEPLOY_SUCCESS"}'
|
execution.output = '{"deployment_status":"DEPLOY_SUCCESS"}'
|
||||||
|
execution.input = '{"plan_name":"overcloud"}'
|
||||||
mistral().executions.get.return_value = execution
|
mistral().executions.get.return_value = execution
|
||||||
mistral().executions.find.return_value = [execution]
|
mistral().executions.list.return_value = [execution]
|
||||||
|
|
||||||
action = deployment.DeploymentStatusAction(self.plan)
|
action = deployment.DeploymentStatusAction(self.plan)
|
||||||
result = action.run(self.ctx)
|
result = action.run(self.ctx)
|
||||||
|
@ -875,8 +879,9 @@ class DeploymentStatusActionTest(base.TestCase):
|
||||||
execution.updated_at = 1
|
execution.updated_at = 1
|
||||||
execution.state = 'SUCCESS'
|
execution.state = 'SUCCESS'
|
||||||
execution.output = '{"deployment_status":"DEPLOY_FAILED"}'
|
execution.output = '{"deployment_status":"DEPLOY_FAILED"}'
|
||||||
|
execution.input = '{"plan_name":"overcloud"}'
|
||||||
mistral().executions.get.return_value = execution
|
mistral().executions.get.return_value = execution
|
||||||
mistral().executions.find.return_value = [execution]
|
mistral().executions.list.return_value = [execution]
|
||||||
|
|
||||||
action = deployment.DeploymentStatusAction(self.plan)
|
action = deployment.DeploymentStatusAction(self.plan)
|
||||||
result = action.run(self.ctx)
|
result = action.run(self.ctx)
|
||||||
|
@ -906,8 +911,9 @@ class DeploymentStatusActionTest(base.TestCase):
|
||||||
execution.updated_at = 1
|
execution.updated_at = 1
|
||||||
execution.state = 'SUCCESS'
|
execution.state = 'SUCCESS'
|
||||||
execution.output = '{"deployment_status":"DEPLOY_SUCCESS"}'
|
execution.output = '{"deployment_status":"DEPLOY_SUCCESS"}'
|
||||||
|
execution.input = '{"plan_name":"overcloud"}'
|
||||||
mistral().executions.get.return_value = execution
|
mistral().executions.get.return_value = execution
|
||||||
mistral().executions.find.return_value = [execution]
|
mistral().executions.list.return_value = [execution]
|
||||||
|
|
||||||
action = deployment.DeploymentStatusAction(self.plan)
|
action = deployment.DeploymentStatusAction(self.plan)
|
||||||
result = action.run(self.ctx)
|
result = action.run(self.ctx)
|
||||||
|
@ -915,6 +921,38 @@ class DeploymentStatusActionTest(base.TestCase):
|
||||||
self.assertEqual(result['status_update'], None)
|
self.assertEqual(result['status_update'], None)
|
||||||
self.assertEqual(result['deployment_status'], None)
|
self.assertEqual(result['deployment_status'], None)
|
||||||
|
|
||||||
|
@mock.patch('tripleo_common.actions.base.TripleOAction.'
|
||||||
|
'get_object_client')
|
||||||
|
@mock.patch('tripleo_common.actions.base.TripleOAction.'
|
||||||
|
'get_workflow_client')
|
||||||
|
@mock.patch('tripleo_common.actions.base.TripleOAction.'
|
||||||
|
'get_orchestration_client')
|
||||||
|
def test_get_deployment_status_different_plan(
|
||||||
|
self, heat, mistral, swift):
|
||||||
|
|
||||||
|
mock_stack = mock.Mock()
|
||||||
|
mock_stack.stack_status = 'COMPLETE'
|
||||||
|
heat().stacks.get.return_value = mock_stack
|
||||||
|
|
||||||
|
body = 'deployment_status: DEPLOY_SUCCESS'
|
||||||
|
swift().get_object.return_value = [mock.Mock(), body]
|
||||||
|
|
||||||
|
execution = mock.Mock()
|
||||||
|
execution.updated_at = 1
|
||||||
|
execution.state = 'SUCCESS'
|
||||||
|
execution.output = '{"deployment_status":"DEPLOY_FAILED"}'
|
||||||
|
execution.input = '{"plan_name":"foobar"}'
|
||||||
|
mistral().executions.get.return_value = execution
|
||||||
|
mistral().executions.list.return_value = [execution]
|
||||||
|
|
||||||
|
action = deployment.DeploymentStatusAction(self.plan)
|
||||||
|
result = action.run(self.ctx)
|
||||||
|
|
||||||
|
self.assertEqual(result['stack_status'], 'COMPLETE')
|
||||||
|
self.assertEqual(result['cd_status'], None)
|
||||||
|
self.assertEqual(result['deployment_status'], 'DEPLOY_SUCCESS')
|
||||||
|
self.assertEqual(result['status_update'], None)
|
||||||
|
|
||||||
|
|
||||||
class DeploymentFailuresActionTest(base.TestCase):
|
class DeploymentFailuresActionTest(base.TestCase):
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue