mirror of
https://github.com/cloudnativelabs/kube-router.git
synced 2025-10-07 07:51:26 +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{
|
||||
PrefixSetName: "podcidrprefixset",
|
||||
PrefixList: []config.Prefix{
|
||||
config.Prefix{
|
||||
{
|
||||
IpPrefix: cidr,
|
||||
},
|
||||
},
|
||||
})
|
||||
nrc.bgpServer.AddDefinedSet(podCidrPrefixSet)
|
||||
err = nrc.bgpServer.ReplaceDefinedSet(podCidrPrefixSet)
|
||||
if err != nil {
|
||||
nrc.bgpServer.AddDefinedSet(podCidrPrefixSet)
|
||||
}
|
||||
|
||||
// creates prefix set to represent all the cluster IP associated with the services
|
||||
clusterIpPrefixList := make([]config.Prefix, 0)
|
||||
@ -273,7 +276,10 @@ func (nrc *NetworkRoutingController) addExportPolicies() error {
|
||||
PrefixSetName: "clusteripprefixset",
|
||||
PrefixList: clusterIpPrefixList,
|
||||
})
|
||||
nrc.bgpServer.AddDefinedSet(clusterIpPrefixSet)
|
||||
err = nrc.bgpServer.ReplaceDefinedSet(clusterIpPrefixSet)
|
||||
if err != nil {
|
||||
nrc.bgpServer.AddDefinedSet(clusterIpPrefixSet)
|
||||
}
|
||||
|
||||
statements := make([]config.Statement, 0)
|
||||
|
||||
@ -302,7 +308,10 @@ func (nrc *NetworkRoutingController) addExportPolicies() error {
|
||||
NeighborSetName: "externalpeerset",
|
||||
NeighborInfoList: externalBgpPeers,
|
||||
})
|
||||
nrc.bgpServer.AddDefinedSet(ns)
|
||||
err = nrc.bgpServer.ReplaceDefinedSet(ns)
|
||||
if err != nil {
|
||||
nrc.bgpServer.AddDefinedSet(ns)
|
||||
}
|
||||
// statement to represent the export policy to permit advertising cluster IP's
|
||||
// only to the global BGP peer or node specific BGP peer
|
||||
statements = append(statements, config.Statement{
|
||||
|
@ -89,7 +89,7 @@ func StartNetworkPolicyWatcher(clientset *kubernetes.Clientset, resyncPeriod tim
|
||||
if v1NetworkPolicy {
|
||||
lw = cache.NewListWatchFromClient(clientset.Networking().RESTClient(), "networkpolicies", metav1.NamespaceAll, fields.Everything())
|
||||
npw.networkPolicyLister, npw.networkPolicyController = cache.NewIndexerInformer(
|
||||
lw, &networking.NetworkPolicy{}, resyncPeriod, eventHandler,
|
||||
lw, &networking.NetworkPolicy{}, resyncPeriod, eventHandler,
|
||||
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
|
||||
)
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user