Skip to content

Commit 101658a

Browse files
murali-reddyaauren
authored andcommitted
incorporate review comments
1 parent 8923618 commit 101658a

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

pkg/controllers/routing/ecmp_vip.go

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)