From 3a6ffa501691b7224bd0588eb687e71ef58d2c44 Mon Sep 17 00:00:00 2001 From: Yi Rae Kim Date: Tue, 24 Oct 2023 09:17:43 -0400 Subject: [PATCH] Fix e2e test case2 status flaky issue Signed-off-by: Yi Rae Kim (cherry picked from commit 6c17e443a8023b7f2f1756e45caef00d617e86bf) --- controllers/common/common_status_update.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/controllers/common/common_status_update.go b/controllers/common/common_status_update.go index 8fa785e7..ac197688 100644 --- a/controllers/common/common_status_update.go +++ b/controllers/common/common_status_update.go @@ -51,7 +51,6 @@ func RootStatusUpdate(ctx context.Context, c client.Client, rootPolicy *policies } log.Info("Updating the root policy status", "RootPolicyName", rootPolicy.Name, "Namespace", rootPolicy.Namespace) - rootPolicy.Status.Status = cpcs rootPolicy.Status.ComplianceState = complianceState rootPolicy.Status.Placement = placements @@ -236,6 +235,16 @@ func GetClusterDecisions( } } + log.V(2).Info("Sorting placements", "RootPolicyName", rootPolicy.Name, "Namespace", rootPolicy.Namespace) + sort.SliceStable(placements, func(i, j int) bool { + pi := placements[i].PlacementBinding + " " + placements[i].Placement + " " + + placements[i].PlacementRule + " " + placements[i].PolicySet + pj := placements[j].PlacementBinding + " " + placements[j].Placement + " " + + placements[j].PlacementRule + " " + placements[j].PolicySet + + return pi < pj + }) + return placements, decisions, nil }