Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Commit

Permalink
Add previousStatus filed to WorkflowModel (#2816)
Browse files Browse the repository at this point in the history
* Add previousStatus filed to WorkflowModel

* Add check to only update previousStatus if status changed

* Update dependency lock files
  • Loading branch information
jxu-nflx authored Mar 9, 2022
1 parent 02a3b4b commit c70a037
Show file tree
Hide file tree
Showing 27 changed files with 3,922 additions and 47,983 deletions.
987 changes: 71 additions & 916 deletions annotations-processor/dependencies.lock

Large diffs are not rendered by default.

673 changes: 12 additions & 661 deletions annotations/dependencies.lock

Large diffs are not rendered by default.

1,949 changes: 148 additions & 1,801 deletions azureblob-storage/dependencies.lock

Large diffs are not rendered by default.

2,249 changes: 152 additions & 2,097 deletions cassandra-persistence/dependencies.lock

Large diffs are not rendered by default.

2,020 changes: 156 additions & 1,864 deletions client-spring/dependencies.lock

Large diffs are not rendered by default.

2,172 changes: 100 additions & 2,072 deletions client/dependencies.lock

Large diffs are not rendered by default.

1,360 changes: 84 additions & 1,276 deletions common/dependencies.lock

Large diffs are not rendered by default.

2,927 changes: 164 additions & 2,763 deletions contribs/dependencies.lock

Large diffs are not rendered by default.

1,756 changes: 103 additions & 1,653 deletions core/dependencies.lock

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions core/src/main/java/com/netflix/conductor/model/WorkflowModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,25 @@ public boolean isSuccessful() {
// Capture the failed taskId if the workflow execution failed because of task failure
private String failedTaskId;

private Status previousStatus;

public Status getPreviousStatus() {
return previousStatus;
}

public void setPreviousStatus(Status status) {
this.previousStatus = status;
}

public Status getStatus() {
return status;
}

public void setStatus(Status status) {
// update previous status if current status changed
if (this.status != status) {
setPreviousStatus(this.status);
}
this.status = status;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,7 @@ public void testRestartWorkflow() {
when(executionDAOFacade.updateWorkflow(any())).thenReturn("");

workflowExecutor.restart(workflow.getWorkflowId(), false);
assertEquals(WorkflowModel.Status.FAILED, workflow.getPreviousStatus());
assertEquals(WorkflowModel.Status.RUNNING, workflow.getStatus());
assertEquals(0, workflow.getEndTime());
assertEquals(0, workflow.getLastRetriedTime());
Expand All @@ -646,6 +647,7 @@ public void testRestartWorkflow() {
when(metadataDAO.getLatestWorkflowDef(workflow.getWorkflowName()))
.thenReturn(Optional.of(workflowDef));
workflowExecutor.restart(workflow.getWorkflowId(), true);
assertEquals(WorkflowModel.Status.COMPLETED, workflow.getPreviousStatus());
assertEquals(WorkflowModel.Status.RUNNING, workflow.getStatus());
assertEquals(0, workflow.getEndTime());
assertEquals(0, workflow.getLastRetriedTime());
Expand Down Expand Up @@ -831,6 +833,7 @@ public void testRetryWorkflow() {
workflowExecutor.retry(workflow.getWorkflowId(), false);

// then:
assertEquals(WorkflowModel.Status.FAILED, workflow.getPreviousStatus());
assertEquals(WorkflowModel.Status.RUNNING, workflow.getStatus());
assertEquals(1, updateWorkflowCalledCounter.get());
assertEquals(1, updateTasksCalledCounter.get());
Expand Down Expand Up @@ -1074,6 +1077,7 @@ public void testRetryWorkflowWithJoinTask() {
workflowExecutor.retry(workflow.getWorkflowId(), false);

assertEquals(6, workflow.getTasks().size());
assertEquals(WorkflowModel.Status.FAILED, workflow.getPreviousStatus());
assertEquals(WorkflowModel.Status.RUNNING, workflow.getStatus());
}

Expand Down Expand Up @@ -1156,7 +1160,9 @@ public void testRetryFromLastFailedSubWorkflowTaskThenStartWithLastFailedTask()
// then
assertEquals(task.getStatus(), TaskModel.Status.COMPLETED);
assertEquals(task1.getStatus(), TaskModel.Status.IN_PROGRESS);
assertEquals(workflow.getPreviousStatus(), WorkflowModel.Status.FAILED);
assertEquals(workflow.getStatus(), WorkflowModel.Status.RUNNING);
assertEquals(subWorkflow.getPreviousStatus(), WorkflowModel.Status.FAILED);
assertEquals(subWorkflow.getStatus(), WorkflowModel.Status.RUNNING);
}

Expand Down Expand Up @@ -1226,6 +1232,7 @@ public void testRetryTimedOutWorkflowWithoutFailedTasks() {
workflowExecutor.retry(workflow.getWorkflowId(), false);

// then
assertEquals(WorkflowModel.Status.TIMED_OUT, workflow.getPreviousStatus());
assertEquals(WorkflowModel.Status.RUNNING, workflow.getStatus());
assertTrue(workflow.getLastRetriedTime() > 0);
assertEquals(1, updateWorkflowCalledCounter.get());
Expand Down Expand Up @@ -1290,6 +1297,7 @@ public void testRerunWorkflow() {
// when:
when(executionDAOFacade.getWorkflowModel(anyString(), anyBoolean())).thenReturn(workflow);

assertEquals(WorkflowModel.Status.FAILED, workflow.getPreviousStatus());
assertEquals(WorkflowModel.Status.RUNNING, workflow.getStatus());
assertNull(workflow.getReasonForIncompletion());
assertEquals(new HashSet<>(), workflow.getFailedReferenceTaskNames());
Expand Down Expand Up @@ -1372,7 +1380,9 @@ public void testRerunSubWorkflow() {

// then:
assertEquals(TaskModel.Status.IN_PROGRESS, task.getStatus());
assertEquals(WorkflowModel.Status.COMPLETED, subWorkflow.getPreviousStatus());
assertEquals(WorkflowModel.Status.RUNNING, subWorkflow.getStatus());
assertEquals(WorkflowModel.Status.COMPLETED, workflow.getPreviousStatus());
assertEquals(WorkflowModel.Status.RUNNING, workflow.getStatus());
}

Expand Down Expand Up @@ -1435,6 +1445,7 @@ public void testRerunWorkflowWithTaskId() {
// when:
when(executionDAOFacade.getWorkflowModel(anyString(), anyBoolean())).thenReturn(workflow);

assertEquals(WorkflowModel.Status.FAILED, workflow.getPreviousStatus());
assertEquals(WorkflowModel.Status.RUNNING, workflow.getStatus());
assertNull(workflow.getReasonForIncompletion());
assertEquals(new HashSet<>(), workflow.getFailedReferenceTaskNames());
Expand Down Expand Up @@ -1492,6 +1503,7 @@ public void testRerunWorkflowWithSyncSystemTaskId() {

// then:
assertEquals(TaskModel.Status.COMPLETED, task2.getStatus());
assertEquals(WorkflowModel.Status.FAILED, workflow.getPreviousStatus());
assertEquals(WorkflowModel.Status.RUNNING, workflow.getStatus());
assertNull(workflow.getReasonForIncompletion());
assertEquals(new HashSet<>(), workflow.getFailedReferenceTaskNames());
Expand Down Expand Up @@ -1576,7 +1588,9 @@ public void testRerunSubWorkflowWithTaskId() {
// then:
assertEquals(TaskModel.Status.SCHEDULED, task2.getStatus());
assertEquals(TaskModel.Status.IN_PROGRESS, task.getStatus());
assertEquals(WorkflowModel.Status.COMPLETED, subWorkflow.getPreviousStatus());
assertEquals(WorkflowModel.Status.RUNNING, subWorkflow.getStatus());
assertEquals(WorkflowModel.Status.COMPLETED, workflow.getPreviousStatus());
assertEquals(WorkflowModel.Status.RUNNING, workflow.getStatus());
}

Expand Down
Loading

0 comments on commit c70a037

Please sign in to comment.