@@ -227,32 +227,30 @@ func (nrc *NetworkRoutingController) OnServiceUpdate(objNew interface{}, objOld
227227 //
228228 // As such, it needs to be handled differently as nrc.handleServiceUpdate only withdraws VIPs if the service
229229 // endpoint is no longer scheduled on this node and its a local type service.
230- withdrawnServiceVips := nrc .getExternalIPsToWithdraw (getServiceObject (objOld ), getServiceObject (objNew ))
230+ nrc .withdrawVIPs (nrc .getExternalIPsToWithdraw (getServiceObject (objOld ), getServiceObject (objNew )))
231+ }
231232
233+ func (nrc * NetworkRoutingController ) getExternalIPsToWithdraw (svcOld , svcNew * v1core.Service ) (out []string ) {
234+ withdrawnServiceVips := make ([]string , 0 )
235+ if svcOld != nil && svcNew != nil {
236+ withdrawnServiceVips = getMissingPrevGen (nrc .getExternalIPs (svcOld ), nrc .getExternalIPs (svcNew ))
237+ }
232238 // ensure external IP to be withdrawn is not used by any other service
233239 allActiveVIPs , _ , err := nrc .getActiveVIPs ()
234240 if err != nil {
235- klog .Errorf ("Failed to get all active VIP's due to: %s" , err .Error ())
241+ klog .Errorf ("failed to get all active VIP's due to: %s" , err .Error ())
236242 return
237243 }
238244 activeVIPsMap := make (map [string ]bool )
239245 for _ , activeVIP := range allActiveVIPs {
240246 activeVIPsMap [activeVIP ] = true
241247 }
242- withdrawVIPs := make ([]string , 0 )
243248 for _ , serviceVIP := range withdrawnServiceVips {
244249 // withdraw VIP only if updated service is the last service using the VIP
245250 if ! activeVIPsMap [serviceVIP ] {
246- withdrawVIPs = append (withdrawVIPs , serviceVIP )
251+ out = append (out , serviceVIP )
247252 }
248253 }
249- nrc .withdrawVIPs (withdrawVIPs )
250- }
251-
252- func (nrc * NetworkRoutingController ) getExternalIPsToWithdraw (svcOld , svcNew * v1core.Service ) (out []string ) {
253- if svcOld != nil && svcNew != nil {
254- out = getMissingPrevGen (nrc .getExternalIPs (svcOld ), nrc .getExternalIPs (svcNew ))
255- }
256254 return
257255}
258256
0 commit comments