Skip to content

Commit

Permalink
fix(core): worker log are displaying the wrong state on terminated tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
tchiotludo committed Jan 8, 2025
1 parent 114c131 commit 68fd36b
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions core/src/main/java/io/kestra/core/runners/Worker.java
Original file line number Diff line number Diff line change
Expand Up @@ -586,13 +586,13 @@ private WorkerTaskResult run(WorkerTask workerTask, Boolean cleanUp) {

try {
// run
WorkerTask workerTaskAttempt = this.runAttempt(workerTask);
workerTask = this.runAttempt(workerTask);

// get last state
TaskRunAttempt lastAttempt = workerTaskAttempt.getTaskRun().lastAttempt();
TaskRunAttempt lastAttempt = workerTask.getTaskRun().lastAttempt();
if (lastAttempt == null) {
throw new IllegalStateException("Can find lastAttempt on taskRun '" +
workerTaskAttempt.getTaskRun().toString(true) + "'"
workerTask.getTaskRun().toString(true) + "'"
);
}
io.kestra.core.models.flows.State.Type state = lastAttempt.getState().getCurrent();
Expand All @@ -605,7 +605,7 @@ private WorkerTaskResult run(WorkerTask workerTask, Boolean cleanUp) {
state = WARNING;
}

if (workerTask.getTask().isAllowFailure() && !workerTaskAttempt.getTaskRun().shouldBeRetried(workerTask.getTask().getRetry()) && state.isFailed()) {
if (workerTask.getTask().isAllowFailure() && !workerTask.getTaskRun().shouldBeRetried(workerTask.getTask().getRetry()) && state.isFailed()) {
state = WARNING;
}

Expand All @@ -614,9 +614,12 @@ private WorkerTaskResult run(WorkerTask workerTask, Boolean cleanUp) {
}

// emit
List<WorkerTaskResult> dynamicWorkerResults = workerTaskAttempt.getRunContext().dynamicWorkerResults();
List<WorkerTaskResult> dynamicWorkerResults = workerTask.getRunContext().dynamicWorkerResults();
List<TaskRun> dynamicTaskRuns = dynamicWorkerResults(dynamicWorkerResults);
WorkerTaskResult workerTaskResult = new WorkerTaskResult(workerTaskAttempt.getTaskRun().withState(state), dynamicTaskRuns);

workerTask = workerTask.withTaskRun(workerTask.getTaskRun().withState(state));

WorkerTaskResult workerTaskResult = new WorkerTaskResult(workerTask.getTaskRun(), dynamicTaskRuns);
this.workerTaskResultQueue.emit(workerTaskResult);
return workerTaskResult;
} catch (QueueException e) {
Expand Down

0 comments on commit 68fd36b

Please sign in to comment.