From 6e759e22f654b109673f9bb9383152979578a647 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E7=84=B6?= Date: Sun, 18 Jan 2026 11:35:20 +0800 Subject: [PATCH 1/2] fix(pipelinerun): fix the issue of massive invalid status updates caused by unordered arrays, which will greatly impact the resource load and stability of the apiserver. --- pkg/reconciler/pipelinerun/pipelinerun.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pkg/reconciler/pipelinerun/pipelinerun.go b/pkg/reconciler/pipelinerun/pipelinerun.go index 1ca2ed0c598..dfbffa5718f 100644 --- a/pkg/reconciler/pipelinerun/pipelinerun.go +++ b/pkg/reconciler/pipelinerun/pipelinerun.go @@ -24,6 +24,7 @@ import ( "path/filepath" "reflect" "regexp" + "sort" "strings" "k8s.io/apimachinery/pkg/util/wait" @@ -1905,6 +1906,18 @@ func updatePipelineRunStatusFromChildRefs(logger *zap.SugaredLogger, pr *v1.Pipe for k := range childRefByName { newChildRefs = append(newChildRefs, *childRefByName[k]) } + + // sorting childRef in a specific order can greatly avoid + // meaningless updates of status caused by unordered arrays. + sort.Slice(newChildRefs, func(i, j int) bool { + if newChildRefs[i].PipelineTaskName == newChildRefs[j].PipelineTaskName { + if newChildRefs[i].Name == newChildRefs[j].Name { + return newChildRefs[i].Kind < newChildRefs[j].Kind + } + return newChildRefs[i].Name < newChildRefs[j].Name + } + return newChildRefs[i].PipelineTaskName < newChildRefs[j].PipelineTaskName + }) pr.Status.ChildReferences = newChildRefs } From 9b213bbf4f7cb19791592494699a4059bb12cf98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E7=84=B6?= Date: Mon, 19 Jan 2026 15:39:00 +0800 Subject: [PATCH 2/2] chore(pipelinerun): remove cmpopts.SortSlices from pkg/reconciler/pipelinerun/pipelinerun_updatestatus_test.go --- pkg/reconciler/pipelinerun/pipelinerun_updatestatus_test.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/reconciler/pipelinerun/pipelinerun_updatestatus_test.go b/pkg/reconciler/pipelinerun/pipelinerun_updatestatus_test.go index c397a81a2aa..ccea760bca2 100644 --- a/pkg/reconciler/pipelinerun/pipelinerun_updatestatus_test.go +++ b/pkg/reconciler/pipelinerun/pipelinerun_updatestatus_test.go @@ -22,7 +22,6 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" "github.com/tektoncd/pipeline/pkg/apis/config" v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" @@ -455,7 +454,7 @@ pipelineTaskName: task actualPrStatus.ChildReferences = fixedChildRefs } - if d := cmp.Diff(tc.expectedPrStatus, actualPrStatus, cmpopts.SortSlices(lessChildReferences)); d != "" { + if d := cmp.Diff(tc.expectedPrStatus, actualPrStatus); d != "" { t.Errorf("expected the PipelineRun status to match %#v. Diff %s", tc.expectedPrStatus, diff.PrintWantGot(d)) } }) @@ -592,7 +591,7 @@ metadata: expectedPRStatus := prStatusFromInputs(prRunningStatus, tc.expectedStatusTRs, tc.expectedStatusRuns, tc.expectedStatusCRs) - if d := cmp.Diff(expectedPRStatus, actualPrStatus, cmpopts.SortSlices(lessChildReferences)); d != "" { + if d := cmp.Diff(expectedPRStatus, actualPrStatus); d != "" { t.Errorf("expected the PipelineRun status to match %#v. Diff %s", expectedPRStatus, diff.PrintWantGot(d)) } })