update BGP export policies on endpoints add event (#508)

This commit is contained in:
Andrew Sy Kim 2018-08-10 10:10:37 -04:00 committed by Murali Reddy
parent 85d8df425d
commit 94e163b5d7

View File

@ -145,7 +145,7 @@ func (nrc *NetworkRoutingController) OnServiceDelete(obj interface{}) {
func (nrc *NetworkRoutingController) newEndpointsEventHandler() cache.ResourceEventHandler {
return cache.ResourceEventHandlerFuncs{
AddFunc: func(obj interface{}) {
nrc.OnEndpointsUpdate(obj)
nrc.OnEndpointsAdd(obj)
},
UpdateFunc: func(oldObj, newObj interface{}) {
nrc.OnEndpointsUpdate(newObj)
@ -158,6 +158,25 @@ func (nrc *NetworkRoutingController) newEndpointsEventHandler() cache.ResourceEv
}
}
// OnEndpointsAdd handles endpoint add events from apiserver
// This method calls OnEndpointsUpdate with the addition of updating BGP export policies
// Calling addExportPolicies here covers the edge case where addExportPolicies fails in
// OnServiceUpdate because the corresponding Endpoint resource for the
// Service was not created yet.
func (nrc *NetworkRoutingController) OnEndpointsAdd(obj interface{}) {
if !nrc.bgpServerStarted {
glog.V(3).Info("Skipping OnAdd event to endpoint, controller still performing bootup full-sync")
return
}
err := nrc.addExportPolicies()
if err != nil {
glog.Errorf("error adding BGP export policies: %s", err)
}
nrc.OnEndpointsUpdate(obj)
}
// OnEndpointsUpdate handles the endpoint updates from the kubernetes API server
func (nrc *NetworkRoutingController) OnEndpointsUpdate(obj interface{}) {
ep, ok := obj.(*v1core.Endpoints)