Skip to content

Commit

Permalink
Stable Sort slices that might get populated in a random order
Browse files Browse the repository at this point in the history
  • Loading branch information
chdxD1 committed Jul 10, 2024
1 parent e5251a4 commit 12bdb03
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions pkg/reconciler/layer3.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,22 @@ func (r *reconcile) reconcileLayer3(l3vnis []networkv1alpha1.VRFRouteConfigurati
l3Configs := []frr.VRFConfiguration{}
taasConfigs := []frr.VRFConfiguration{}
for key := range vrfConfigMap {
allConfigs = append(allConfigs, vrfConfigMap[key])
l3Configs = append(l3Configs, vrfConfigMap[key])
vrfConfig := vrfConfigMap[key]
// Sort all lists in VRFConfigurations that are fetched from Kubernetes and might be in random order
sort.SliceStable(vrfConfig.Export, func(i, j int) bool {
return vrfConfig.Export[i].Seq < vrfConfig.Export[j].Seq
})
sort.SliceStable(vrfConfig.Import, func(i, j int) bool {
return vrfConfig.Import[i].Seq < vrfConfig.Import[j].Seq
})
sort.SliceStable(vrfConfig.AggregateIPv4, func(i, j int) bool {
return vrfConfig.AggregateIPv4[i] < vrfConfig.AggregateIPv4[j]
})
sort.SliceStable(vrfConfig.AggregateIPv6, func(i, j int) bool {
return vrfConfig.AggregateIPv6[i] < vrfConfig.AggregateIPv6[j]
})
allConfigs = append(allConfigs, vrfConfig)
l3Configs = append(l3Configs, vrfConfig)
}
for key := range vrfFromTaas {
allConfigs = append(allConfigs, vrfFromTaas[key])
Expand Down

0 comments on commit 12bdb03

Please sign in to comment.