@VisibleForTesting
    void checkWorkflowTimeout(WorkflowModel workflow) {
        WorkflowDef workflowDef = workflow.getWorkflowDefinition();
        if (workflowDef == null) {
            LOGGER.warn("Missing workflow definition : {}", workflow.getWorkflowId());
            return;
        }
        if (workflow.getStatus().isTerminal() || workflowDef.getTimeoutSeconds() <= 0) {
            return;
        }

        long timeout = 1000L * workflowDef.getTimeoutSeconds();
        long now = System.currentTimeMillis();
        long elapsedTime =
                workflow.getLastRetriedTime() > 0
                        ? now - workflow.getLastRetriedTime()
                        : now - workflow.getCreateTime();

        if (elapsedTime < timeout) {
            return;
        }

        String reason =
                String.format(
                        "Workflow timed out after %d seconds. Timeout configured as %d seconds. "
                                + "Timeout policy configured to %s",
                        elapsedTime / 1000L,
                        workflowDef.getTimeoutSeconds(),
                        workflowDef.getTimeoutPolicy().name());

        switch (workflowDef.getTimeoutPolicy()) {
            case ALERT_ONLY:
                LOGGER.info("{} {}", workflow.getWorkflowId(), reason);
                Monitors.recordWorkflowTermination(
                        workflow.getWorkflowName(),
                        WorkflowModel.Status.TIMED_OUT,
                        workflow.getOwnerApp());
                return;
            case TIME_OUT_WF:
                throw new TerminateWorkflowException(reason, WorkflowModel.Status.TIMED_OUT);
        }
    }
Updates the workflow output.

@param workflow the workflow instance
@param task if not null, the output of this task will be copied to workflow output if no
    output parameters are specified in the workflow definition if null, the output of the
    last task in the workflow will be copied to workflow output of no output parameters are
    specified in the workflow definition
core/src/main/java/com/netflix/conductor/core/execution/DeciderService.java