mirror of
https://github.com/cloudnativelabs/kube-router.git
synced 2025-10-07 16:01:08 +02:00
network_route_controller: Avoid redundant policy sets (#98)
* gofmt * route_controller: Avoid redundant DefinedSet adds
This commit is contained in:
parent
f9ae00be10
commit
f8174a66be
@ -256,12 +256,15 @@ func (nrc *NetworkRoutingController) addExportPolicies() error {
|
|||||||
podCidrPrefixSet, err := table.NewPrefixSet(config.PrefixSet{
|
podCidrPrefixSet, err := table.NewPrefixSet(config.PrefixSet{
|
||||||
PrefixSetName: "podcidrprefixset",
|
PrefixSetName: "podcidrprefixset",
|
||||||
PrefixList: []config.Prefix{
|
PrefixList: []config.Prefix{
|
||||||
config.Prefix{
|
{
|
||||||
IpPrefix: cidr,
|
IpPrefix: cidr,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
err = nrc.bgpServer.ReplaceDefinedSet(podCidrPrefixSet)
|
||||||
|
if err != nil {
|
||||||
nrc.bgpServer.AddDefinedSet(podCidrPrefixSet)
|
nrc.bgpServer.AddDefinedSet(podCidrPrefixSet)
|
||||||
|
}
|
||||||
|
|
||||||
// creates prefix set to represent all the cluster IP associated with the services
|
// creates prefix set to represent all the cluster IP associated with the services
|
||||||
clusterIpPrefixList := make([]config.Prefix, 0)
|
clusterIpPrefixList := make([]config.Prefix, 0)
|
||||||
@ -273,7 +276,10 @@ func (nrc *NetworkRoutingController) addExportPolicies() error {
|
|||||||
PrefixSetName: "clusteripprefixset",
|
PrefixSetName: "clusteripprefixset",
|
||||||
PrefixList: clusterIpPrefixList,
|
PrefixList: clusterIpPrefixList,
|
||||||
})
|
})
|
||||||
|
err = nrc.bgpServer.ReplaceDefinedSet(clusterIpPrefixSet)
|
||||||
|
if err != nil {
|
||||||
nrc.bgpServer.AddDefinedSet(clusterIpPrefixSet)
|
nrc.bgpServer.AddDefinedSet(clusterIpPrefixSet)
|
||||||
|
}
|
||||||
|
|
||||||
statements := make([]config.Statement, 0)
|
statements := make([]config.Statement, 0)
|
||||||
|
|
||||||
@ -302,7 +308,10 @@ func (nrc *NetworkRoutingController) addExportPolicies() error {
|
|||||||
NeighborSetName: "externalpeerset",
|
NeighborSetName: "externalpeerset",
|
||||||
NeighborInfoList: externalBgpPeers,
|
NeighborInfoList: externalBgpPeers,
|
||||||
})
|
})
|
||||||
|
err = nrc.bgpServer.ReplaceDefinedSet(ns)
|
||||||
|
if err != nil {
|
||||||
nrc.bgpServer.AddDefinedSet(ns)
|
nrc.bgpServer.AddDefinedSet(ns)
|
||||||
|
}
|
||||||
// statement to represent the export policy to permit advertising cluster IP's
|
// statement to represent the export policy to permit advertising cluster IP's
|
||||||
// only to the global BGP peer or node specific BGP peer
|
// only to the global BGP peer or node specific BGP peer
|
||||||
statements = append(statements, config.Statement{
|
statements = append(statements, config.Statement{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user