Skip to content

Commit

Permalink
feat(core): add system.restarted: true label when changing the status…
Browse files Browse the repository at this point in the history
… of a task
  • Loading branch information
loicmathieu committed Jan 27, 2025
1 parent c52fdd0 commit 4f2d35f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ private Execution markAs(final Execution execution, Flow flow, String taskRunId,
taskRun -> taskRun.getId().equals(taskRunId)
);

Execution newExecution = execution;
Execution newExecution = execution.withMetadata(execution.getMetadata().nextAttempt());

for (String s : taskRunToRestart) {
TaskRun originalTaskRun = newExecution.findTaskRunByTaskRunId(s);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ void markAsEachPara() throws Exception {
Execution restart = executionService.markAs(execution, flow, execution.findTaskRunByTaskIdAndValue("2-1_seq", List.of("value 1")).getId(), State.Type.FAILED);

assertThat(restart.getState().getCurrent(), is(State.Type.RESTARTED));
assertThat(restart.getMetadata().getAttemptNumber(), is(2));
assertThat(restart.getState().getHistories(), hasSize(4));
assertThat(restart.getTaskRunList(), hasSize(11));
assertThat(restart.findTaskRunByTaskIdAndValue("1_each", List.of()).getState().getCurrent(), is(State.Type.RUNNING));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,11 @@ public Execution changeState(
Flow flow = flowRepository.findByExecution(execution.get());

Execution replay = executionService.markAs(execution.get(), flow, stateRequest.getTaskRunId(), stateRequest.getState());
List<Label> newLabels = new ArrayList<>(replay.getLabels());
if (!newLabels.contains(new Label(Label.RESTARTED, "true"))) {
newLabels.add(new Label(Label.RESTARTED, "true"));
}
replay = replay.withLabels(newLabels);
executionQueue.emit(replay);
eventPublisher.publishEvent(new CrudEvent<>(replay, execution.get(), CrudEventType.UPDATE));

Expand Down

0 comments on commit 4f2d35f

Please sign in to comment.