Skip to content

Commit

Permalink
fix(core): restarted & retry execution don't display log in realtime
Browse files Browse the repository at this point in the history
close #573
  • Loading branch information
tchiotludo committed Aug 2, 2022
1 parent 3e999cf commit 5a565bf
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,14 @@ public boolean hasTaskRunJoinable(TaskRun taskRun) {
return true;
}

// attempts & retry need to be saved
if (
(current.getAttempts() == null && taskRun.getAttempts() != null) ||
(current.getAttempts() != null && taskRun.getAttempts() != null && current.getAttempts().size() < taskRun.getAttempts().size())
) {
return true;
}

// same status
if (current.getState().getCurrent() == taskRun.getState().getCurrent()) {
return false;
Expand Down
17 changes: 17 additions & 0 deletions core/src/test/java/io/kestra/core/runners/RetryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,25 @@

import io.kestra.core.models.executions.Execution;
import io.kestra.core.models.flows.State;
import io.kestra.core.queues.QueueFactoryInterface;
import io.kestra.core.queues.QueueInterface;
import jakarta.inject.Inject;
import jakarta.inject.Named;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeoutException;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;

public class RetryTest extends AbstractMemoryRunnerTest {
@Inject
@Named(QueueFactoryInterface.EXECUTION_NAMED)
protected QueueInterface<Execution> executionQueue;

@Test
void retrySuccess() throws TimeoutException {
Execution execution = runnerUtils.runOne("io.kestra.tests", "retry-success");
Expand All @@ -22,9 +32,16 @@ void retrySuccess() throws TimeoutException {

@Test
void retryFailed() throws TimeoutException {
List<Execution> executions = new ArrayList<>();
executionQueue.receive(executions::add);

Execution execution = runnerUtils.runOne("io.kestra.tests", "retry-failed");

assertThat(execution.getTaskRunList(), hasSize(2));
assertThat(execution.getTaskRunList().get(0).getAttempts(), hasSize(5));

// be sure attempts are available on queue
assertThat(executions.size(), is(19));
assertThat(executions.get(8).getTaskRunList().get(0).getAttempts().size(), is(3));
}
}

0 comments on commit 5a565bf

Please sign in to comment.