File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -1490,6 +1490,10 @@ func (nrc *NetworkRoutingController) OnEndpointsUpdate(obj interface{}) {
14901490		return 
14911491	}
14921492
1493+ 	if  isEndpointsForLeaderElection (ep ) {
1494+ 		return 
1495+ 	}
1496+ 
14931497	svc , err  :=  nrc .serviceForEndpoints (ep )
14941498	if  err  !=  nil  {
14951499		glog .Errorf ("failed to convert endpoints resource to service: %s" , err )
Original file line number Diff line number Diff line change @@ -49,6 +49,8 @@ const (
4949	svcHairpinAnnotation    =  "kube-router.io/service.hairpin" 
5050	svcLocalAnnotation      =  "kube-router.io/service.local" 
5151	svcSkipLbIpsAnnotation  =  "kube-router.io/service.skiplbips" 
52+ 
53+ 	LeaderElectionRecordAnnotationKey  =  "control-plane.alpha.kubernetes.io/leader" 
5254)
5355
5456var  (
@@ -353,6 +355,16 @@ func (nsc *NetworkServicesController) OnEndpointsUpdate(obj interface{}) {
353355
354356	glog .V (1 ).Info ("Received endpoints update from watch API" )
355357
358+ 	ep , ok  :=  obj .(* api.Endpoints )
359+ 	if  ! ok  {
360+ 		glog .Error ("could not convert endpoints update object to *v1.Endpoints" )
361+ 		return 
362+ 	}
363+ 
364+ 	if  isEndpointsForLeaderElection (ep ) {
365+ 		return 
366+ 	}
367+ 
356368	// build new endpoints map to reflect the change 
357369	newEndpointsMap  :=  nsc .buildEndpointsInfo ()
358370
@@ -1617,6 +1629,11 @@ func (ln *linuxNetworking) setupRoutesForExternalIPForDSR(serviceInfoMap service
16171629	return  nil 
16181630}
16191631
1632+ func  isEndpointsForLeaderElection (ep  * api.Endpoints ) bool  {
1633+ 	_ , isLeaderElection  :=  ep .Annotations [LeaderElectionRecordAnnotationKey ]
1634+ 	return  isLeaderElection 
1635+ }
1636+ 
16201637// unique identifier for a load-balanced service (namespace + name + portname) 
16211638func  generateServiceId (namespace , svcName , port  string ) string  {
16221639	return  namespace  +  "-"  +  svcName  +  "-"  +  port 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments