3
3
import com .fasterxml .jackson .databind .ObjectMapper ;
4
4
import io .kestra .core .contexts .KestraContext ;
5
5
import io .kestra .core .exceptions .DeserializationException ;
6
- import io .kestra .core .exceptions .IllegalVariableEvaluationException ;
7
6
import io .kestra .core .exceptions .InternalException ;
8
- import io .kestra .core .exceptions .KestraRuntimeException ;
9
7
import io .kestra .core .metrics .MetricRegistry ;
10
8
import io .kestra .core .models .executions .*;
11
9
import io .kestra .core .models .executions .statistics .ExecutionCount ;
@@ -543,14 +541,15 @@ private void executionQueue(Either<Execution, DeserializationException> either)
543
541
544
542
// worker task
545
543
if (!executor .getWorkerTasks ().isEmpty ()) {
544
+ List <WorkerTaskResult > workerTaskResults = new ArrayList <>();
546
545
executor
547
546
.getWorkerTasks ()
548
547
.stream ()
549
548
.filter (workerTask -> this .deduplicateWorkerTask (execution , executorState , workerTask .getTaskRun ()))
550
549
.forEach (throwConsumer (workerTask -> {
551
550
try {
552
551
if (!TruthUtils .isTruthy (workerTask .getRunContext ().render (workerTask .getTask ().getRunIf ()))) {
553
- workerTaskResultQueue . emit (new WorkerTaskResult (workerTask .getTaskRun ().withState (State .Type .SKIPPED )));
552
+ workerTaskResults . add (new WorkerTaskResult (workerTask .getTaskRun ().withState (State .Type .SKIPPED )));
554
553
} else {
555
554
if (workerTask .getTask ().isSendToWorkerTask ()) {
556
555
Optional <WorkerGroup > maybeWorkerGroup = workerGroupService .resolveGroupFromJob (workerTask );
@@ -559,14 +558,20 @@ private void executionQueue(Either<Execution, DeserializationException> either)
559
558
workerJobQueue .emit (workerGroupKey , workerTask );
560
559
}
561
560
if (workerTask .getTask ().isFlowable ()) {
562
- workerTaskResultQueue . emit (new WorkerTaskResult (workerTask .getTaskRun ().withState (State .Type .RUNNING )));
561
+ workerTaskResults . add (new WorkerTaskResult (workerTask .getTaskRun ().withState (State .Type .RUNNING )));
563
562
}
564
563
}
565
564
} catch (Exception e ) {
566
- workerTaskResultQueue . emit (new WorkerTaskResult (workerTask .getTaskRun ().withState (State .Type .FAILED )));
565
+ workerTaskResults . add (new WorkerTaskResult (workerTask .getTaskRun ().withState (State .Type .FAILED )));
567
566
workerTask .getRunContext ().logger ().error ("Failed to evaluate the runIf condition for task {}. Cause: {}" , workerTask .getTask ().getId (), e .getMessage (), e );
568
567
}
569
568
}));
569
+
570
+ try {
571
+ executorService .addWorkerTaskResults (executor , flow , workerTaskResults );
572
+ } catch (InternalException e ) {
573
+ log .error ("Unable to add a worker task result to the execution" , e );
574
+ }
570
575
}
571
576
572
577
// subflow execution results
0 commit comments