diff --git a/controllers/gce/controller/utils.go b/controllers/gce/controller/utils.go index b7d78e088..8360fa36a 100644 --- a/controllers/gce/controller/utils.go +++ b/controllers/gce/controller/utils.go @@ -384,7 +384,7 @@ func (t *GCETranslator) getHTTPProbe(l map[string]string, targetPort intstr.IntO for _, pod := range pl { logStr := fmt.Sprintf("Pod %v matching service selectors %v (targetport %+v)", pod.Name, l, targetPort) for _, c := range pod.Spec.Containers { - if c.ReadinessProbe == nil || c.ReadinessProbe.Handler.HTTPGet == nil { + if !isSimpleHTTPProbe(c.ReadinessProbe) { continue } for _, p := range c.Ports { @@ -403,6 +403,15 @@ func (t *GCETranslator) getHTTPProbe(l map[string]string, targetPort intstr.IntO return nil, nil } +// isSimpleHTTPProbe returns true if the given Probe is: +// - an HTTPGet probe, as opposed to a tcp or exec probe +// - has a scheme of HTTP, as opposed to HTTPS +// - has no special host or headers fields +func isSimpleHTTPProbe(probe *api.Probe) bool { + return (probe != nil && probe.Handler.HTTPGet != nil && probe.Handler.HTTPGet.Host == "" && + probe.Handler.HTTPGet.Scheme == api.URISchemeHTTP && len(probe.Handler.HTTPGet.HTTPHeaders) == 0) +} + // HealthCheck returns the http readiness probe for the endpoint backing the // given nodePort. If no probe is found it returns a health check with "" as // the request path, callers are responsible for swapping this out for the