mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 10:51:29 +00:00
kube-proxy: code optimization
Signed-off-by: kerthcet <kerthcet@gmail.com>
This commit is contained in:
parent
baf6014e0c
commit
2b7373f336
@ -296,14 +296,15 @@ func NewServiceChangeTracker(makeServiceInfo makeServicePortFunc, ipFamily v1.IP
|
|||||||
// Delete item
|
// Delete item
|
||||||
// - pass <service, nil> as the <previous, current> pair.
|
// - pass <service, nil> as the <previous, current> pair.
|
||||||
func (sct *ServiceChangeTracker) Update(previous, current *v1.Service) bool {
|
func (sct *ServiceChangeTracker) Update(previous, current *v1.Service) bool {
|
||||||
|
// This is unexpected, we should return false directly.
|
||||||
|
if previous == nil && current == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
svc := current
|
svc := current
|
||||||
if svc == nil {
|
if svc == nil {
|
||||||
svc = previous
|
svc = previous
|
||||||
}
|
}
|
||||||
// previous == nil && current == nil is unexpected, we should return false directly.
|
|
||||||
if svc == nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
metrics.ServiceChangesTotal.Inc()
|
metrics.ServiceChangesTotal.Inc()
|
||||||
namespacedName := types.NamespacedName{Namespace: svc.Namespace, Name: svc.Name}
|
namespacedName := types.NamespacedName{Namespace: svc.Namespace, Name: svc.Name}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user