Skip to content

Commit 68525b4

Browse files
DrRebusrclsilver
authored andcommitted
fix(plugin): Fixed batch not finishing once completed
Signed-off-by: Ruben Tordjman <[email protected]>
1 parent dd6039e commit 68525b4

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

engine/engine_test.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -1463,8 +1463,8 @@ func TestBatch(t *testing.T) {
14631463
}
14641464
}
14651465

1466-
// checking if the parent task is picked up after that the subtask is resolved.
1467-
// need to sleep a bit because the parent task is resumed asynchronously
1466+
// checking if the parent task is picked up after the subtask is resolved.
1467+
// We need to sleep a bit because the parent task is resumed asynchronously
14681468
ti := time.Second
14691469
i := time.Duration(0)
14701470
for i < ti {
@@ -1489,7 +1489,6 @@ func TestBatch(t *testing.T) {
14891489

14901490
time.Sleep(time.Millisecond * 10)
14911491
i += time.Millisecond * 10
1492-
14931492
}
14941493
assert.Equal(t, resolution.StateDone, res.State)
14951494
}

pkg/plugins/builtin/batch/batch.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,9 @@ func populateBatch(
236236
// Computing how many tasks to start
237237
remaining := int64(len(conf.Inputs)) - tasksStarted
238238
toStart := int64(conf.SubBatchSize) - running // How many tasks can be started
239-
if remaining < toStart {
240-
toStart = remaining // There's less tasks to start remaining than the amount of available running slots
239+
if remaining < toStart || conf.SubBatchSize == 0 {
240+
// There's less tasks remaining to start than the amount of available running slots or slots are unlimited
241+
toStart = remaining
241242
}
242243

243244
args := batch.TaskArgs{
@@ -310,7 +311,7 @@ func increaseRunMax(dbp zesty.DBProvider, parentTaskID string, batchStepName str
310311
return err
311312
}
312313

313-
if t.Resolution != nil {
314+
if t.Resolution == nil {
314315
return fmt.Errorf("resolution not found for step '%s' of task '%s'", batchStepName, parentTaskID)
315316
}
316317

0 commit comments

Comments
 (0)