mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 06:54:01 +00:00
Merge pull request #45208 from MrHohn/proxy-localendpoint-logic
Automatic merge from submit-queue (batch tested with PRs 44590, 44969, 45325, 45208, 44714) Fix onlylocal endpoint's healthcheck nodeport logic I was in the middle of rebasing #41162, surprisingly found the healthcheck nodeport logic in kube-proxy is still buggy. Separate this fix out as it isn't GA related. /assign @freehan @thockin **Release note**: ```release-note NONE ```
This commit is contained in:
commit
32335ee473
@ -105,9 +105,6 @@ func NeedsHealthCheck(service *api.Service) bool {
|
|||||||
|
|
||||||
// GetServiceHealthCheckNodePort Return health check node port annotation for service, if one exists
|
// GetServiceHealthCheckNodePort Return health check node port annotation for service, if one exists
|
||||||
func GetServiceHealthCheckNodePort(service *api.Service) int32 {
|
func GetServiceHealthCheckNodePort(service *api.Service) int32 {
|
||||||
if !NeedsHealthCheck(service) {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
// First check the alpha annotation and then the beta. This is so existing
|
// 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.
|
// 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
|
// If they transition to beta, there's no way to go back to alpha without
|
||||||
|
@ -105,9 +105,6 @@ func NeedsHealthCheck(service *v1.Service) bool {
|
|||||||
|
|
||||||
// GetServiceHealthCheckNodePort Return health check node port annotation for service, if one exists
|
// GetServiceHealthCheckNodePort Return health check node port annotation for service, if one exists
|
||||||
func GetServiceHealthCheckNodePort(service *v1.Service) int32 {
|
func GetServiceHealthCheckNodePort(service *v1.Service) int32 {
|
||||||
if !NeedsHealthCheck(service) {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
// First check the alpha annotation and then the beta. This is so existing
|
// 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.
|
// 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
|
// If they transition to beta, there's no way to go back to alpha without
|
||||||
|
@ -181,11 +181,10 @@ func newServiceInfo(serviceName proxy.ServicePortName, port *api.ServicePort, se
|
|||||||
copy(info.loadBalancerSourceRanges, service.Spec.LoadBalancerSourceRanges)
|
copy(info.loadBalancerSourceRanges, service.Spec.LoadBalancerSourceRanges)
|
||||||
copy(info.externalIPs, service.Spec.ExternalIPs)
|
copy(info.externalIPs, service.Spec.ExternalIPs)
|
||||||
|
|
||||||
if info.onlyNodeLocalEndpoints {
|
if apiservice.NeedsHealthCheck(service) {
|
||||||
p := apiservice.GetServiceHealthCheckNodePort(service)
|
p := apiservice.GetServiceHealthCheckNodePort(service)
|
||||||
if p == 0 {
|
if p == 0 {
|
||||||
glog.Errorf("Service does not contain necessary annotation %v",
|
glog.Errorf("Service %q has no healthcheck nodeport", serviceName)
|
||||||
apiservice.BetaAnnotationHealthCheckNodePort)
|
|
||||||
} else {
|
} else {
|
||||||
info.healthCheckNodePort = int(p)
|
info.healthCheckNodePort = int(p)
|
||||||
}
|
}
|
||||||
@ -644,16 +643,10 @@ func updateServiceMap(
|
|||||||
// computing this incrementally similarly to serviceMap.
|
// computing this incrementally similarly to serviceMap.
|
||||||
hcServices = make(map[types.NamespacedName]uint16)
|
hcServices = make(map[types.NamespacedName]uint16)
|
||||||
for svcPort, info := range serviceMap {
|
for svcPort, info := range serviceMap {
|
||||||
if info.onlyNodeLocalEndpoints {
|
if info.healthCheckNodePort != 0 {
|
||||||
hcServices[svcPort.NamespacedName] = uint16(info.healthCheckNodePort)
|
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
|
return syncRequired, hcServices, staleServices
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user