From 1cac5db85631a5b0f0b0c7799627380c9199c1a1 Mon Sep 17 00:00:00 2001 From: Zihong Zheng Date: Mon, 1 May 2017 20:36:44 -0700 Subject: [PATCH] Fix onlylocal endpoint's healthcheck nodeport logic --- pkg/api/service/util.go | 3 --- pkg/api/v1/service/util.go | 3 --- pkg/proxy/iptables/proxier.go | 13 +++---------- 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/pkg/api/service/util.go b/pkg/api/service/util.go index f8561718172..ddf2f68d6a1 100644 --- a/pkg/api/service/util.go +++ b/pkg/api/service/util.go @@ -105,9 +105,6 @@ func NeedsHealthCheck(service *api.Service) bool { // GetServiceHealthCheckNodePort Return health check node port annotation for service, if one exists func GetServiceHealthCheckNodePort(service *api.Service) int32 { - if !NeedsHealthCheck(service) { - return 0 - } // First check the alpha annotation and then the beta. This is so existing // Services continue to work till the user decides to transition to beta. // If they transition to beta, there's no way to go back to alpha without diff --git a/pkg/api/v1/service/util.go b/pkg/api/v1/service/util.go index 338e8f8e0fa..8ee8a54d6d3 100644 --- a/pkg/api/v1/service/util.go +++ b/pkg/api/v1/service/util.go @@ -105,9 +105,6 @@ func NeedsHealthCheck(service *v1.Service) bool { // GetServiceHealthCheckNodePort Return health check node port annotation for service, if one exists func GetServiceHealthCheckNodePort(service *v1.Service) int32 { - if !NeedsHealthCheck(service) { - return 0 - } // First check the alpha annotation and then the beta. This is so existing // Services continue to work till the user decides to transition to beta. // If they transition to beta, there's no way to go back to alpha without diff --git a/pkg/proxy/iptables/proxier.go b/pkg/proxy/iptables/proxier.go index 26f03889ec5..b3796aeee50 100644 --- a/pkg/proxy/iptables/proxier.go +++ b/pkg/proxy/iptables/proxier.go @@ -181,11 +181,10 @@ func newServiceInfo(serviceName proxy.ServicePortName, port *api.ServicePort, se copy(info.loadBalancerSourceRanges, service.Spec.LoadBalancerSourceRanges) copy(info.externalIPs, service.Spec.ExternalIPs) - if info.onlyNodeLocalEndpoints { + if apiservice.NeedsHealthCheck(service) { p := apiservice.GetServiceHealthCheckNodePort(service) if p == 0 { - glog.Errorf("Service does not contain necessary annotation %v", - apiservice.BetaAnnotationHealthCheckNodePort) + glog.Errorf("Service %q has no healthcheck nodeport", serviceName) } else { info.healthCheckNodePort = int(p) } @@ -644,16 +643,10 @@ func updateServiceMap( // computing this incrementally similarly to serviceMap. hcServices = make(map[types.NamespacedName]uint16) for svcPort, info := range serviceMap { - if info.onlyNodeLocalEndpoints { + if info.healthCheckNodePort != 0 { hcServices[svcPort.NamespacedName] = uint16(info.healthCheckNodePort) } } - for nsn, port := range hcServices { - if port == 0 { - glog.Errorf("Service %q has no healthcheck nodeport", nsn) - delete(hcServices, nsn) - } - } return syncRequired, hcServices, staleServices }