@@ -502,14 +502,14 @@ func ResolvePipelineRunTask(
502
502
}
503
503
rprt .CustomTask = isCustomTask (ctx , rprt )
504
504
if rprt .IsCustomTask () {
505
- rprt .RunName = getRunName (pipelineRun .Status .Runs , task .Name , pipelineRun .Name )
505
+ rprt .RunName = getRunName (pipelineRun .Status .Runs , pipelineRun . Status . ChildReferences , task .Name , pipelineRun .Name )
506
506
run , err := getRun (rprt .RunName )
507
507
if err != nil && ! errors .IsNotFound (err ) {
508
508
return nil , fmt .Errorf ("error retrieving Run %s: %w" , rprt .RunName , err )
509
509
}
510
510
rprt .Run = run
511
511
} else {
512
- rprt .TaskRunName = GetTaskRunName (pipelineRun .Status .TaskRuns , task .Name , pipelineRun .Name )
512
+ rprt .TaskRunName = GetTaskRunName (pipelineRun .Status .TaskRuns , pipelineRun . Status . ChildReferences , task .Name , pipelineRun .Name )
513
513
514
514
// Find the Task that this PipelineTask is using
515
515
var (
@@ -560,7 +560,7 @@ func ResolvePipelineRunTask(
560
560
561
561
// Get all conditions that this pipelineTask will be using, if any
562
562
if len (task .Conditions ) > 0 {
563
- rcc , err := resolveConditionChecks (& task , pipelineRun .Status .TaskRuns , rprt .TaskRunName , getTaskRun , getCondition , providedResources )
563
+ rcc , err := resolveConditionChecks (& task , pipelineRun .Status .TaskRuns , pipelineRun . Status . ChildReferences , rprt .TaskRunName , getTaskRun , getCondition , providedResources )
564
564
if err != nil {
565
565
return nil , err
566
566
}
@@ -571,7 +571,16 @@ func ResolvePipelineRunTask(
571
571
}
572
572
573
573
// getConditionCheckName should return a unique name for a `ConditionCheck` if one has not already been defined, and the existing one otherwise.
574
- func getConditionCheckName (taskRunStatus map [string ]* v1beta1.PipelineRunTaskRunStatus , trName , conditionRegisterName string ) string {
574
+ func getConditionCheckName (taskRunStatus map [string ]* v1beta1.PipelineRunTaskRunStatus , childRefs []v1beta1.ChildStatusReference , trName , conditionRegisterName string ) string {
575
+ for _ , cr := range childRefs {
576
+ if cr .Name == trName {
577
+ for _ , cc := range cr .ConditionChecks {
578
+ if cc .ConditionName == conditionRegisterName {
579
+ return cc .ConditionCheckName
580
+ }
581
+ }
582
+ }
583
+ }
575
584
trStatus , ok := taskRunStatus [trName ]
576
585
if ok && trStatus .ConditionChecks != nil {
577
586
for k , v := range trStatus .ConditionChecks {
@@ -585,7 +594,13 @@ func getConditionCheckName(taskRunStatus map[string]*v1beta1.PipelineRunTaskRunS
585
594
}
586
595
587
596
// GetTaskRunName should return a unique name for a `TaskRun` if one has not already been defined, and the existing one otherwise.
588
- func GetTaskRunName (taskRunsStatus map [string ]* v1beta1.PipelineRunTaskRunStatus , ptName , prName string ) string {
597
+ func GetTaskRunName (taskRunsStatus map [string ]* v1beta1.PipelineRunTaskRunStatus , childRefs []v1beta1.ChildStatusReference , ptName , prName string ) string {
598
+ for _ , cr := range childRefs {
599
+ if cr .Kind == "TaskRun" && cr .PipelineTaskName == ptName {
600
+ return cr .Name
601
+ }
602
+ }
603
+
589
604
for k , v := range taskRunsStatus {
590
605
if v .PipelineTaskName == ptName {
591
606
return k
@@ -597,16 +612,23 @@ func GetTaskRunName(taskRunsStatus map[string]*v1beta1.PipelineRunTaskRunStatus,
597
612
598
613
// getRunName should return a unique name for a `Run` if one has not already
599
614
// been defined, and the existing one otherwise.
600
- func getRunName (runsStatus map [string ]* v1beta1.PipelineRunRunStatus , ptName , prName string ) string {
615
+ func getRunName (runsStatus map [string ]* v1beta1.PipelineRunRunStatus , childRefs []v1beta1.ChildStatusReference , ptName , prName string ) string {
616
+ for _ , cr := range childRefs {
617
+ if cr .Kind == "Run" && cr .PipelineTaskName == ptName {
618
+ return cr .Name
619
+ }
620
+ }
621
+
601
622
for k , v := range runsStatus {
602
623
if v .PipelineTaskName == ptName {
603
624
return k
604
625
}
605
626
}
627
+
606
628
return kmeta .ChildName (prName , fmt .Sprintf ("-%s" , ptName ))
607
629
}
608
630
609
- func resolveConditionChecks (pt * v1beta1.PipelineTask , taskRunStatus map [string ]* v1beta1.PipelineRunTaskRunStatus , taskRunName string , getTaskRun resources.GetTaskRun , getCondition GetCondition , providedResources map [string ]* resourcev1alpha1.PipelineResource ) ([]* ResolvedConditionCheck , error ) {
631
+ func resolveConditionChecks (pt * v1beta1.PipelineTask , taskRunStatus map [string ]* v1beta1.PipelineRunTaskRunStatus , childRefs []v1beta1. ChildStatusReference , taskRunName string , getTaskRun resources.GetTaskRun , getCondition GetCondition , providedResources map [string ]* resourcev1alpha1.PipelineResource ) ([]* ResolvedConditionCheck , error ) {
610
632
rccs := []* ResolvedConditionCheck {}
611
633
for i := range pt .Conditions {
612
634
ptc := pt .Conditions [i ]
@@ -619,7 +641,7 @@ func resolveConditionChecks(pt *v1beta1.PipelineTask, taskRunStatus map[string]*
619
641
Msg : err .Error (),
620
642
}
621
643
}
622
- conditionCheckName := getConditionCheckName (taskRunStatus , taskRunName , crName )
644
+ conditionCheckName := getConditionCheckName (taskRunStatus , childRefs , taskRunName , crName )
623
645
// TODO(#3133): Also handle Custom Task Runs (getRun here)
624
646
cctr , err := getTaskRun (conditionCheckName )
625
647
if err != nil {
0 commit comments