Skip to content

Commit

Permalink
Fix e2e test case2 status flaky issue
Browse files Browse the repository at this point in the history
Signed-off-by: Yi Rae Kim <[email protected]>
(cherry picked from commit 6c17e44)
  • Loading branch information
yiraeChristineKim authored and mprahl committed Oct 24, 2023
1 parent f423823 commit 0a8f89d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion controllers/common/common_status_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 0a8f89d

Please sign in to comment.