in maestro-engine/src/main/java/com/netflix/maestro/engine/utils/AggregatedViewHelper.java [231:284]
static void computeAndSetAggregatedInstanceStatus(
WorkflowInstance currentInstance, WorkflowInstanceAggregatedInfo aggregated) {
if (!currentInstance.getStatus().isTerminal()
|| currentInstance.isFreshRun()
|| !currentInstance.getStatus().equals(WorkflowInstance.Status.SUCCEEDED)) {
aggregated.setWorkflowInstanceStatus(currentInstance.getStatus());
return;
}
boolean succeeded = true;
for (StepAggregatedView stepAggregated : aggregated.getStepAggregatedViews().values()) {
WorkflowInstance.Status workflowStatus =
STEP_INSTANCE_STATUS_TO_WORKFLOW_INSTANCE_STATUS.get(stepAggregated.getStatus());
switch (workflowStatus) {
case FAILED:
// if any step is failed overall status is failed
aggregated.setWorkflowInstanceStatus(WorkflowInstance.Status.FAILED);
return;
case TIMED_OUT:
// if any are timed out, we want to keep going to search for failed steps
aggregated.setWorkflowInstanceStatus(WorkflowInstance.Status.TIMED_OUT);
break;
case STOPPED:
// prioritize timed out status before stopped
if (aggregated.getWorkflowInstanceStatus() != WorkflowInstance.Status.TIMED_OUT) {
aggregated.setWorkflowInstanceStatus(WorkflowInstance.Status.STOPPED);
}
break;
case SUCCEEDED:
break;
case CREATED:
// there are steps in NOT_CREATED STATUS and the workflow instance cannot be SUCCEEDED.
succeeded = false;
break;
default:
// should never reach here with IN_PROGRESS status;
throw new MaestroInternalError(
"State %s is not expected during aggregated status computation for"
+ " workflow_id = %s ; workflow_instance_id = %s ; workflow_run_id = %s",
workflowStatus,
currentInstance.getWorkflowId(),
currentInstance.getWorkflowInstanceId(),
currentInstance.getWorkflowRunId());
}
}
if (aggregated.getWorkflowInstanceStatus() == null) {
if (succeeded) {
aggregated.setWorkflowInstanceStatus(WorkflowInstance.Status.SUCCEEDED);
} else {
aggregated.setWorkflowInstanceStatus(
currentInstance.getAggregatedInfo().getWorkflowInstanceStatus());
}
}
}