Merge pull request #112208 from kerthcet/cleanup/code-optimization

kube-proxy: code optimization for readability
This commit is contained in:
Kubernetes Prow Robot 2022-09-04 05:42:36 -07:00 committed by GitHub
commit bcea98234f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -296,14 +296,15 @@ func NewServiceChangeTracker(makeServiceInfo makeServicePortFunc, ipFamily v1.IP
// Delete item
// - pass <service, nil> as the <previous, current> pair.
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
if svc == nil {
svc = previous
}
// previous == nil && current == nil is unexpected, we should return false directly.
if svc == nil {
return false
}
metrics.ServiceChangesTotal.Inc()
namespacedName := types.NamespacedName{Namespace: svc.Namespace, Name: svc.Name}