From fe6c35bc6ba040e4f0c13a6576393cfeeb60b504 Mon Sep 17 00:00:00 2001 From: Timo Reimann Date: Thu, 4 May 2017 11:34:05 +0200 Subject: [PATCH] [Kubernetes] Ignore missing pass host header annotation. A missing annotation would previously be handled in the default error case, causing a noisy warning-level log message to be generated each time. We add another case statement to ignore the case where the annotation is missing from the annotations map. Also piggybacking a minor improvement to the log message. --- provider/kubernetes/kubernetes.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/provider/kubernetes/kubernetes.go b/provider/kubernetes/kubernetes.go index 947274e7c..61e8bc842 100644 --- a/provider/kubernetes/kubernetes.go +++ b/provider/kubernetes/kubernetes.go @@ -156,14 +156,16 @@ func (p *Provider) loadIngresses(k8sClient Client) (*types.Configuration, error) PassHostHeader := p.getPassHostHeader() - passHostHeaderAnnotation := i.Annotations["traefik.frontend.passHostHeader"] - switch passHostHeaderAnnotation { - case "true": - PassHostHeader = true - case "false": + passHostHeaderAnnotation, ok := i.Annotations["traefik.frontend.passHostHeader"] + switch { + case !ok: + // No op. + case passHostHeaderAnnotation == "false": PassHostHeader = false + case passHostHeaderAnnotation == "true": + PassHostHeader = true default: - log.Warnf("Unknown value of %s for traefik.frontend.passHostHeader, falling back to %s", passHostHeaderAnnotation, PassHostHeader) + log.Warnf("Unknown value '%s' for traefik.frontend.passHostHeader, falling back to %s", passHostHeaderAnnotation, PassHostHeader) } if realm := i.Annotations["ingress.kubernetes.io/auth-realm"]; realm != "" && realm != traefikDefaultRealm { return nil, errors.New("no realm customization supported")