Skip to content

Commit

Permalink
fix(core): Continue WaitFor loop if tasks are not failed
Browse files Browse the repository at this point in the history
close #6031
  • Loading branch information
Skraye committed Dec 24, 2024
1 parent 93e7ff2 commit 0b6b5d3
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/src/main/java/io/kestra/plugin/core/flow/WaitFor.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public boolean childTaskRunExecuted(Execution execution, TaskRun parentTaskRun)
.stream()
.filter(t -> t.getParentTaskRunId() != null
&& t.getParentTaskRunId().equals(parentTaskRun.getId())
&& t.getState().isSuccess()
&& t.getState().isTerminated()
).count() == tasks.size();

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,11 @@ public void waitforMultipleTasksFailed() throws TimeoutException, QueueException
assertThat(execution.getState().getCurrent(), is(State.Type.FAILED));
assertThat(execution.getTaskRunList().getLast().attemptNumber(), is(1));
}

public void waitForChildTaskWarning() throws TimeoutException, QueueException {
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "waitfor-child-task-warning");

assertThat(execution.getState().getCurrent(), is(State.Type.FAILED));
assertThat(execution.getTaskRunList().getLast().attemptNumber(), greaterThan(1));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
id: waitfor-child-task-warning
namespace: io.kestra.tests

tasks:
- id: loop
type: io.kestra.plugin.core.flow.WaitFor
condition: "{{ outputs.check_migration_task.vars['status'] == 'FINISHED' }}"
failOnMaxReached: true
checkFrequency:
interval: PT5S
maxDuration: PT10S
tasks:

## forcing a Warning
- id: allow_failure
type: io.kestra.plugin.scripts.shell.Commands
taskRunner:
type: io.kestra.plugin.core.runner.Process
allowFailure: true
commands:
- exit 1

- id: check_migration_task
type: io.kestra.plugin.scripts.shell.Commands
taskRunner:
type: io.kestra.plugin.scripts.runner.docker.Docker
entryPoint: []
containerImage: "ubuntu:latest"
commands:
- "echo '::{\"outputs\":{\"status\": \"INPROGRESS\"}}::'"
6 changes: 6 additions & 0 deletions jdbc/src/test/java/io/kestra/jdbc/runner/JdbcRunnerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,12 @@ void waitforMultipleTasksFailed() throws Exception {
waitForTestCaseTest.waitforMultipleTasksFailed();
}

@Test
@LoadFlows({"flows/valids/waitfor-child-task-warning.yaml"})
void waitForChildTaskWarning() throws Exception {
waitForTestCaseTest.waitForChildTaskWarning();
}

@Test
@LoadFlows({"flows/valids/inputs-large.yaml"})
void flowTooLarge() throws Exception {
Expand Down

0 comments on commit 0b6b5d3

Please sign in to comment.