mirror of
https://github.com/cloudnativelabs/kube-router.git
synced 2025-09-30 04:21:07 +02:00
fix(bgp policy): sort the slice items before deep equal(#1188)
This commit is contained in:
parent
8e7d585217
commit
73b7c22ae4
@ -5,6 +5,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -125,7 +126,14 @@ func (nrc *NetworkRoutingController) addServiceVIPsDefinedSet() error {
|
|||||||
&gobgpapi.AddDefinedSetRequest{DefinedSet: clusterIPPrefixSet})
|
&gobgpapi.AddDefinedSetRequest{DefinedSet: clusterIPPrefixSet})
|
||||||
}
|
}
|
||||||
|
|
||||||
if reflect.DeepEqual(advIPPrefixList, currentDefinedSet.Prefixes) {
|
currentPrefixes := currentDefinedSet.Prefixes
|
||||||
|
sort.SliceStable(advIPPrefixList, func(i, j int) bool {
|
||||||
|
return advIPPrefixList[i].IpPrefix < advIPPrefixList[j].IpPrefix
|
||||||
|
})
|
||||||
|
sort.SliceStable(currentPrefixes, func(i, j int) bool {
|
||||||
|
return currentPrefixes[i].IpPrefix < currentPrefixes[j].IpPrefix
|
||||||
|
})
|
||||||
|
if reflect.DeepEqual(advIPPrefixList, currentPrefixes) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
toAdd := make([]*gobgpapi.Prefix, 0)
|
toAdd := make([]*gobgpapi.Prefix, 0)
|
||||||
@ -243,7 +251,10 @@ func (nrc *NetworkRoutingController) addiBGPPeersDefinedSet() ([]string, error)
|
|||||||
return iBGPPeerCIDRs, err
|
return iBGPPeerCIDRs, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if reflect.DeepEqual(iBGPPeerCIDRs, currentDefinedSet.List) {
|
currentCIDRs := currentDefinedSet.List
|
||||||
|
sort.Strings(iBGPPeerCIDRs)
|
||||||
|
sort.Strings(currentCIDRs)
|
||||||
|
if reflect.DeepEqual(iBGPPeerCIDRs, currentCIDRs) {
|
||||||
return iBGPPeerCIDRs, nil
|
return iBGPPeerCIDRs, nil
|
||||||
}
|
}
|
||||||
toAdd := make([]string, 0)
|
toAdd := make([]string, 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user