Skip to content

Commit 2412c2b

Browse files
committed
fix issue with failing child tasks in run_tasks_concurrent
1 parent 0ae73dc commit 2412c2b

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

pkg/coordinator/tasks/run_task_matrix/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ The `run_task_matrix` task is designed to execute a specified task multiple time
1414
- **`failTaskCount`**:\
1515
The number of child tasks that may to fail (result status "failure") before the `run_task_matrix` task to stops and returns a failure result. A value of 0 means that the appearance of any failure in child tasks will cause the overall task to fail.
1616

17+
- **`failOnUndecided`**:\
18+
If set to true, the `run_task_matrix` task will fail if neither the `succeedTaskCount` nor the `failTaskCount` is reached.
19+
1720
- **`matrixValues`**:\
1821
An array of values that form the matrix. Each value in this array is used to run the child task with a different input.
1922

@@ -33,7 +36,9 @@ Default settings for the `run_task_matrix` task:
3336
runConcurrent: false
3437
succeedTaskCount: 0
3538
failTaskCount: 0
39+
failOnUndecided: true
3640
matrixValues: []
3741
matrixVar: ""
3842
task: {}
3943
```
44+

pkg/coordinator/tasks/run_task_matrix/config.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ type Config struct {
1616
// number of failed child tasks to make this task fail (0 = all tasks)
1717
FailTaskCount uint64 `yaml:"failTaskCount" json:"failTaskCount"`
1818

19+
// fail task if neither succeedTaskCount nor failTaskCount is reached, but all tasks completed
20+
FailOnUndecided bool `yaml:"failOnUndecided" json:"failOnUndecided"`
21+
1922
// matrix variable name
2023
MatrixValues []interface{} `yaml:"matrixValues" json:"matrixValues"`
2124

@@ -27,7 +30,9 @@ type Config struct {
2730
}
2831

2932
func DefaultConfig() Config {
30-
return Config{}
33+
return Config{
34+
FailOnUndecided: true,
35+
}
3136
}
3237

3338
func (c *Config) Validate() error {

pkg/coordinator/tasks/run_task_matrix/task.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,12 @@ func (t *Task) Execute(ctx context.Context) error {
229229
if !taskComplete {
230230
taskComplete = true
231231

232-
t.ctx.SetResult(types.TaskResultSuccess)
232+
if t.config.FailOnUndecided {
233+
t.ctx.SetResult(types.TaskResultFailure)
234+
} else {
235+
t.ctx.SetResult(types.TaskResultSuccess)
236+
}
237+
233238
t.logger.Infof("all child tasks completed (%v success, %v failure)", successCount, failureCount)
234239
}
235240
}

pkg/coordinator/tasks/run_tasks_concurrent/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ The `run_tasks_concurrent` task allows for the parallel execution of multiple ta
1111
- **`failTaskCount`**:\
1212
The minimum number of child tasks that need to complete with a "failure" result for the `run_tasks_concurrent` task to stop and return a failure result. A value of 1 means the overall task will fail as soon as one child task fails.
1313

14+
- **`failOnUndecided`**:\
15+
If set to true, the `run_tasks_concurrent` task will fail if neither the `succeedTaskCount` nor the `failTaskCount` is reached.
16+
1417
- **`newVariableScope`**:\
1518
If set to true, a new variable scope will be created for the child tasks, if not, the child tasks will use the same variable scope as the parent task.
1619

@@ -26,6 +29,7 @@ Default settings for the `run_tasks_concurrent` task:
2629
config:
2730
succeedTaskCount: 0
2831
failTaskCount: 1
32+
failOnUndecided: false
2933
newVariableScope: true
3034
tasks: []
3135
```

0 commit comments

Comments
 (0)