diff --git a/pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go b/pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go index 1bda4964837..e6c8a89ed8f 100644 --- a/pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go +++ b/pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go @@ -80,6 +80,10 @@ func (t ResolvedPipelineTask) isDone(facts *PipelineRunFacts) bool { // isRunning returns true only if the task is neither succeeded, cancelled nor failed func (t ResolvedPipelineTask) isRunning() bool { switch { + case t.IsCustomTask() && t.IsMatrixed(): + if len(t.Runs) == 0 { + return false + } case t.IsCustomTask(): if t.Run == nil { return false diff --git a/pkg/reconciler/pipelinerun/resources/pipelinerunresolution_test.go b/pkg/reconciler/pipelinerun/resources/pipelinerunresolution_test.go index 41e25228d3b..00ccefa4bcb 100644 --- a/pkg/reconciler/pipelinerun/resources/pipelinerunresolution_test.go +++ b/pkg/reconciler/pipelinerun/resources/pipelinerunresolution_test.go @@ -4052,6 +4052,13 @@ func TestIsRunning(t *testing.T) { PipelineTask: matrixedPipelineTask, }, want: false, + }, { + name: "matrixed runs not started", + rpt: ResolvedPipelineTask{ + CustomTask: true, + PipelineTask: matrixedPipelineTask, + }, + want: false, }, { name: "matrixed taskruns running", rpt: ResolvedPipelineTask{ @@ -4059,6 +4066,14 @@ func TestIsRunning(t *testing.T) { TaskRuns: []*v1beta1.TaskRun{makeStarted(trs[0]), makeStarted(trs[1])}, }, want: true, + }, { + name: "matrixed runs running", + rpt: ResolvedPipelineTask{ + CustomTask: true, + PipelineTask: matrixedPipelineTask, + Runs: []*v1alpha1.Run{makeRunStarted(runs[0]), makeRunStarted(runs[1])}, + }, + want: true, }, { name: "one matrixed taskrun running", rpt: ResolvedPipelineTask{ @@ -4066,6 +4081,14 @@ func TestIsRunning(t *testing.T) { TaskRuns: []*v1beta1.TaskRun{makeStarted(trs[0]), makeSucceeded(trs[1])}, }, want: true, + }, { + name: "one matrixed run running", + rpt: ResolvedPipelineTask{ + CustomTask: true, + PipelineTask: matrixedPipelineTask, + Runs: []*v1alpha1.Run{makeRunStarted(runs[0]), makeRunSucceeded(runs[1])}, + }, + want: true, }, { name: "matrixed taskruns succeeded", rpt: ResolvedPipelineTask{ @@ -4073,6 +4096,14 @@ func TestIsRunning(t *testing.T) { TaskRuns: []*v1beta1.TaskRun{makeSucceeded(trs[0]), makeSucceeded(trs[1])}, }, want: false, + }, { + name: "matrixed runs succeeded", + rpt: ResolvedPipelineTask{ + CustomTask: true, + PipelineTask: matrixedPipelineTask, + Runs: []*v1alpha1.Run{makeRunSucceeded(runs[0]), makeRunSucceeded(runs[1])}, + }, + want: false, }, { name: "matrixed taskruns failed", rpt: ResolvedPipelineTask{ @@ -4080,6 +4111,14 @@ func TestIsRunning(t *testing.T) { TaskRuns: []*v1beta1.TaskRun{makeFailed(trs[0]), makeFailed(trs[1])}, }, want: false, + }, { + name: "matrixed runs failed", + rpt: ResolvedPipelineTask{ + CustomTask: true, + PipelineTask: matrixedPipelineTask, + Runs: []*v1alpha1.Run{makeRunFailed(runs[0]), makeRunFailed(runs[1])}, + }, + want: false, }, { name: "one matrixed taskrun failed, one matrixed taskrun running", rpt: ResolvedPipelineTask{ @@ -4087,6 +4126,14 @@ func TestIsRunning(t *testing.T) { TaskRuns: []*v1beta1.TaskRun{makeFailed(trs[0]), makeStarted(trs[1])}, }, want: true, + }, { + name: "one matrixed run failed, one matrixed run running", + rpt: ResolvedPipelineTask{ + CustomTask: true, + PipelineTask: matrixedPipelineTask, + Runs: []*v1alpha1.Run{makeRunFailed(runs[0]), makeRunStarted(runs[1])}, + }, + want: true, }, { name: "matrixed taskruns failed: retries remaining", rpt: ResolvedPipelineTask{ @@ -4094,6 +4141,14 @@ func TestIsRunning(t *testing.T) { TaskRuns: []*v1beta1.TaskRun{makeFailed(trs[0]), makeFailed(trs[1])}, }, want: true, + }, { + name: "matrixed runs failed: retries remaining", + rpt: ResolvedPipelineTask{ + CustomTask: true, + PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), + Runs: []*v1alpha1.Run{makeRunFailed(runs[0]), makeRunFailed(runs[1])}, + }, + want: true, }, { name: "matrixed taskruns failed: one taskrun with retries remaining", rpt: ResolvedPipelineTask{ @@ -4101,6 +4156,14 @@ func TestIsRunning(t *testing.T) { TaskRuns: []*v1beta1.TaskRun{makeFailed(trs[0]), withRetries(makeFailed(trs[1]))}, }, want: true, + }, { + name: "matrixed runs failed: one run with retries remaining", + rpt: ResolvedPipelineTask{ + CustomTask: true, + PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), + Runs: []*v1alpha1.Run{makeRunFailed(runs[0]), withRunRetries(makeRunFailed(runs[1]))}, + }, + want: true, }, { name: "matrixed taskruns failed: no retries remaining", rpt: ResolvedPipelineTask{ @@ -4108,6 +4171,14 @@ func TestIsRunning(t *testing.T) { TaskRuns: []*v1beta1.TaskRun{withRetries(makeFailed(trs[0])), withRetries(makeFailed(trs[1]))}, }, want: false, + }, { + name: "matrixed runs failed: no retries remaining", + rpt: ResolvedPipelineTask{ + CustomTask: true, + PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), + Runs: []*v1alpha1.Run{withRunRetries(makeRunFailed(runs[0])), withRunRetries(makeRunFailed(runs[1]))}, + }, + want: false, }, { name: "matrixed taskruns cancelled", rpt: ResolvedPipelineTask{ @@ -4115,6 +4186,14 @@ func TestIsRunning(t *testing.T) { TaskRuns: []*v1beta1.TaskRun{withCancelled(makeFailed(trs[0])), withCancelled(makeFailed(trs[1]))}, }, want: false, + }, { + name: "matrixed runs cancelled", + rpt: ResolvedPipelineTask{ + CustomTask: true, + PipelineTask: matrixedPipelineTask, + Runs: []*v1alpha1.Run{withRunCancelled(makeRunFailed(runs[0])), withRunCancelled(makeRunFailed(runs[1]))}, + }, + want: false, }, { name: "one matrixed taskrun cancelled, one matrixed taskrun running", rpt: ResolvedPipelineTask{ @@ -4122,6 +4201,14 @@ func TestIsRunning(t *testing.T) { TaskRuns: []*v1beta1.TaskRun{withCancelled(makeFailed(trs[0])), makeStarted(trs[1])}, }, want: true, + }, { + name: "one matrixed run cancelled, one matrixed run running", + rpt: ResolvedPipelineTask{ + CustomTask: true, + PipelineTask: matrixedPipelineTask, + Runs: []*v1alpha1.Run{withRunCancelled(makeRunFailed(runs[0])), makeRunStarted(runs[1])}, + }, + want: true, }, { name: "matrixed taskruns cancelled but not failed", rpt: ResolvedPipelineTask{ @@ -4129,6 +4216,14 @@ func TestIsRunning(t *testing.T) { TaskRuns: []*v1beta1.TaskRun{withCancelled(newTaskRun(trs[0])), withCancelled(newTaskRun(trs[1]))}, }, want: true, + }, { + name: "matrixed runs cancelled but not failed", + rpt: ResolvedPipelineTask{ + CustomTask: true, + PipelineTask: matrixedPipelineTask, + Runs: []*v1alpha1.Run{withRunCancelled(newRun(runs[0])), withRunCancelled(newRun(runs[1]))}, + }, + want: true, }, { name: "one matrixed taskrun cancelled but not failed", rpt: ResolvedPipelineTask{ @@ -4136,6 +4231,14 @@ func TestIsRunning(t *testing.T) { TaskRuns: []*v1beta1.TaskRun{withCancelled(newTaskRun(trs[0])), makeStarted(trs[1])}, }, want: true, + }, { + name: "one matrixed run cancelled but not failed", + rpt: ResolvedPipelineTask{ + CustomTask: true, + PipelineTask: matrixedPipelineTask, + Runs: []*v1alpha1.Run{withRunCancelled(newRun(runs[0])), makeRunStarted(runs[1])}, + }, + want: true, }, { name: "matrixed taskruns cancelled: retries remaining", rpt: ResolvedPipelineTask{ @@ -4143,6 +4246,14 @@ func TestIsRunning(t *testing.T) { TaskRuns: []*v1beta1.TaskRun{withCancelled(makeFailed(trs[0])), withCancelled(makeFailed(trs[1]))}, }, want: false, + }, { + name: "matrixed runs cancelled: retries remaining", + rpt: ResolvedPipelineTask{ + CustomTask: true, + PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), + Runs: []*v1alpha1.Run{withRunCancelled(makeRunFailed(runs[0])), withRunCancelled(makeRunFailed(runs[1]))}, + }, + want: false, }, { name: "one matrixed taskrun cancelled: retries remaining, one matrixed taskrun running", rpt: ResolvedPipelineTask{ @@ -4150,6 +4261,14 @@ func TestIsRunning(t *testing.T) { TaskRuns: []*v1beta1.TaskRun{withCancelled(makeFailed(trs[0])), makeStarted(trs[1])}, }, want: true, + }, { + name: "one matrixed run cancelled: retries remaining, one matrixed run running", + rpt: ResolvedPipelineTask{ + CustomTask: true, + PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), + Runs: []*v1alpha1.Run{withRunCancelled(makeRunFailed(runs[0])), makeRunStarted(runs[1])}, + }, + want: true, }, { name: "matrixed taskruns cancelled: no retries remaining", rpt: ResolvedPipelineTask{ @@ -4157,6 +4276,14 @@ func TestIsRunning(t *testing.T) { TaskRuns: []*v1beta1.TaskRun{withCancelled(withRetries(makeFailed(trs[0]))), withCancelled(withRetries(makeFailed(trs[1])))}, }, want: false, + }, { + name: "matrixed runs cancelled: no retries remaining", + rpt: ResolvedPipelineTask{ + CustomTask: true, + PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), + Runs: []*v1alpha1.Run{withRunCancelled(withRunRetries(makeRunFailed(runs[0]))), withRunCancelled(withRunRetries(makeRunFailed(runs[1])))}, + }, + want: false, }, { name: "one matrixed taskrun cancelled: no retries remaining, one matrixed taskrun running", rpt: ResolvedPipelineTask{ @@ -4164,6 +4291,14 @@ func TestIsRunning(t *testing.T) { TaskRuns: []*v1beta1.TaskRun{withCancelled(withRetries(makeFailed(trs[0]))), makeStarted(trs[1])}, }, want: true, + }, { + name: "one matrixed run cancelled: no retries remaining, one matrixed run running", + rpt: ResolvedPipelineTask{ + CustomTask: true, + PipelineTask: withPipelineTaskRetries(*matrixedPipelineTask, 1), + Runs: []*v1alpha1.Run{withRunCancelled(withRunRetries(makeRunFailed(runs[0]))), makeRunStarted(runs[1])}, + }, + want: true, }} { t.Run(tc.name, func(t *testing.T) { if got := tc.rpt.isRunning(); got != tc.want {