in maestro-engine/src/main/java/com/netflix/maestro/engine/tasks/MaestroTask.java [591:665]
private void tryUpdateByAction(
WorkflowSummary workflowSummary, Step stepDefinition, StepRuntimeSummary runtimeSummary) {
StepInstance.Status status = runtimeSummary.getRuntimeState().getStatus();
if (status.isTerminal()) {
return;
}
Optional<StepAction> stepAction =
actionDao.tryGetAction(workflowSummary, stepDefinition.getId());
stepAction.ifPresent(
action -> {
// add this special check because a task in a non-skippable status might be waked up
if (action.getAction() == Actions.StepInstanceAction.SKIP
&& !Actions.STEP_INSTANCE_STATUS_TO_ACTION_MAP
.getOrDefault(status, Collections.emptyList())
.contains(action.getAction())) {
LOG.info(
"Workflow instance {} get an action [{}] unsupported by action map on the step {}, ignore it.",
workflowSummary.getIdentity(),
action.getAction(),
runtimeSummary.getIdentity());
return; // cannot take this action in the current status
}
// not check STEP_INSTANCE_STATUS_TO_ACTION_MAP as the action should be already validated
switch (action.getAction()) {
case RESTART:
if (status == StepInstance.Status.NOT_CREATED) {
runtimeSummary.setStepRunParams(action.getRunParams());
runtimeSummary.setRestartConfig(action.getRestartConfig());
runtimeSummary.markCreated(tracingManager);
break;
} else {
if (status == StepInstance.Status.RUNNING) {
runtimeSummary.setPendingAction(action);
}
return;
}
case KILL: // mark the step fatally failed, kill job
runtimeSummary.configIgnoreFailureMode(action, workflowSummary);
// fall through
case STOP: // mark the step stopped, kill job
case SKIP: // mark the step skipped, terminate job and then continue with next step
if (status != StepInstance.Status.NOT_CREATED) {
// might throw retryable error if it is still terminating.
terminate(
workflowSummary,
runtimeSummary,
action.getTerminalStatus(
workflowSummary.getWorkflowId(), workflowSummary.getWorkflowInstanceId()));
break;
} else {
return;
}
case BYPASS_STEP_DEPENDENCIES:
if (status != StepInstance.Status.WAITING_FOR_SIGNALS) {
LOG.info("Ignore bypass dependency action as current status is: {}", status);
// todo better to delete byPassStepDependencies action
} else {
runtimeSummary.byPassSignalDependencies(action.getUser(), action.getCreateTime());
// skip adding the timeline info for action as its already taken care in the
// byPassStepDependencies.
}
return;
default:
LOG.info("Ignore unknown action: {}", action);
return;
}
LOG.info(
"Workflow instance {} take an action [{}] on the step {}",
workflowSummary.getIdentity(),
action.getAction(),
runtimeSummary.getIdentity());
runtimeSummary.addTimeline(action.toTimelineEvent());
});
}