From 86072e1dbdc12bf45064df0efa6d77dfca58c983 Mon Sep 17 00:00:00 2001 From: changzhen Date: Tue, 26 Apr 2022 19:40:14 +0800 Subject: [PATCH] sort the aggregatedStatus in rb/crb by the clusterName Signed-off-by: changzhen --- pkg/util/helper/workstatus.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/util/helper/workstatus.go b/pkg/util/helper/workstatus.go index bda73548e..021d90f4d 100644 --- a/pkg/util/helper/workstatus.go +++ b/pkg/util/helper/workstatus.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "reflect" + "sort" "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -193,6 +194,9 @@ func assembleWorkStatus(works []workv1alpha1.Work, workload *unstructured.Unstru } } + sort.Slice(statuses, func(i, j int) bool { + return statuses[i].ClusterName < statuses[j].ClusterName + }) return statuses, nil }