From a2a0c80acbdbecfb5150d76988cc791157cae991 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Mon, 14 May 2018 10:18:03 +0200 Subject: [PATCH] Fix segment backend name --- docs/configuration/backends/docker.md | 2 +- docs/configuration/backends/marathon.md | 2 +- docs/configuration/backends/rancher.md | 2 +- provider/docker/config.go | 2 +- provider/docker/config_segment_test.go | 2 +- provider/docker/deprecated_service.go | 2 +- provider/docker/deprecated_service_test.go | 4 ++-- provider/label/label.go | 6 +----- provider/label/names.go | 2 -- provider/rancher/config.go | 2 +- 10 files changed, 10 insertions(+), 16 deletions(-) diff --git a/docs/configuration/backends/docker.md b/docs/configuration/backends/docker.md index 006de85dd..da9ef6d4c 100644 --- a/docs/configuration/backends/docker.md +++ b/docs/configuration/backends/docker.md @@ -284,12 +284,12 @@ Segment labels override the default behavior. | Label | Description | |---------------------------------------------------------------------------|-------------------------------------------------------------| +| `traefik..backend=BACKEND` | Same as `traefik.backend` | | `traefik..domain=DOMAIN` | Same as `traefik.domain` | | `traefik..port=PORT` | Same as `traefik.port` | | `traefik..protocol=http` | Same as `traefik.protocol` | | `traefik..weight=10` | Same as `traefik.weight` | | `traefik..frontend.auth.basic=EXPR` | Same as `traefik.frontend.auth.basic` | -| `traefik..frontend.backend=BACKEND` | Same as `traefik.frontend.backend` | | `traefik..frontend.entryPoints=https` | Same as `traefik.frontend.entryPoints` | | `traefik..frontend.errors..backend=NAME` | Same as `traefik.frontend.errors..backend` | | `traefik..frontend.errors..query=PATH` | Same as `traefik.frontend.errors..query` | diff --git a/docs/configuration/backends/marathon.md b/docs/configuration/backends/marathon.md index 1e5268795..84ba2c5f6 100644 --- a/docs/configuration/backends/marathon.md +++ b/docs/configuration/backends/marathon.md @@ -255,13 +255,13 @@ Segment labels override the default behavior. | Label | Description | |---------------------------------------------------------------------------|-------------------------------------------------------------| +| `traefik..backend=BACKEND` | Same as `traefik.backend` | | `traefik..domain=DOMAIN` | Same as `traefik.domain` | | `traefik..portIndex=1` | Same as `traefik.portIndex` | | `traefik..port=PORT` | Same as `traefik.port` | | `traefik..protocol=http` | Same as `traefik.protocol` | | `traefik..weight=10` | Same as `traefik.weight` | | `traefik..frontend.auth.basic=EXPR` | Same as `traefik.frontend.auth.basic` | -| `traefik..frontend.backend=BACKEND` | Same as `traefik.frontend.backend` | | `traefik..frontend.entryPoints=https` | Same as `traefik.frontend.entryPoints` | | `traefik..frontend.errors..backend=NAME` | Same as `traefik.frontend.errors..backend` | | `traefik..frontend.errors..query=PATH` | Same as `traefik.frontend.errors..query` | diff --git a/docs/configuration/backends/rancher.md b/docs/configuration/backends/rancher.md index 0954ba34a..e9e566ead 100644 --- a/docs/configuration/backends/rancher.md +++ b/docs/configuration/backends/rancher.md @@ -222,12 +222,12 @@ Segment labels override the default behavior. | Label | Description | |---------------------------------------------------------------------------|-------------------------------------------------------------| +| `traefik..backend=BACKEND` | Same as `traefik.backend` | | `traefik..domain=DOMAIN` | Same as `traefik.domain` | | `traefik..port=PORT` | Same as `traefik.port` | | `traefik..protocol=http` | Same as `traefik.protocol` | | `traefik..weight=10` | Same as `traefik.weight` | | `traefik..frontend.auth.basic=EXPR` | Same as `traefik.frontend.auth.basic` | -| `traefik..frontend.backend=BACKEND` | Same as `traefik.frontend.backend` | | `traefik..frontend.entryPoints=https` | Same as `traefik.frontend.entryPoints` | | `traefik..frontend.errors..backend=NAME` | Same as `traefik.frontend.errors..backend` | | `traefik..frontend.errors..query=PATH` | Same as `traefik.frontend.errors..query` | diff --git a/provider/docker/config.go b/provider/docker/config.go index 6e3421812..7ee1e2c76 100644 --- a/provider/docker/config.go +++ b/provider/docker/config.go @@ -262,7 +262,7 @@ func isBackendLBSwarm(container dockerData) bool { } func getSegmentBackendName(container dockerData) string { - if value := label.GetStringValue(container.SegmentLabels, label.TraefikFrontendBackend, ""); len(value) > 0 { + if value := label.GetStringValue(container.SegmentLabels, label.TraefikBackend, ""); len(value) > 0 { return provider.Normalize(container.ServiceName + "-" + value) } diff --git a/provider/docker/config_segment_test.go b/provider/docker/config_segment_test.go index 02e6c6311..caeeaee82 100644 --- a/provider/docker/config_segment_test.go +++ b/provider/docker/config_segment_test.go @@ -251,7 +251,7 @@ func TestSegmentBuildConfiguration(t *testing.T) { "traefik.sauternes.port": "2503", "traefik.sauternes.protocol": "https", "traefik.sauternes.weight": "80", - "traefik.sauternes.frontend.backend": "foobar", + "traefik.sauternes.backend": "foobar", "traefik.sauternes.frontend.passHostHeader": "false", "traefik.sauternes.frontend.rule": "Path:/mypath", "traefik.sauternes.frontend.priority": "5000", diff --git a/provider/docker/deprecated_service.go b/provider/docker/deprecated_service.go index d6180d445..a709cf0d5 100644 --- a/provider/docker/deprecated_service.go +++ b/provider/docker/deprecated_service.go @@ -88,7 +88,7 @@ func extractServicePortV1(labelName string) []string { // Extract backend from labels for a given service and a given docker container // Deprecated func getServiceBackendNameV1(container dockerData, serviceName string) string { - if value, ok := getServiceLabelsV1(container, serviceName)[label.SuffixFrontendBackend]; ok { + if value, ok := getServiceLabelsV1(container, serviceName)[label.SuffixBackend]; ok { return provider.Normalize(container.ServiceName + "-" + value) } return provider.Normalize(container.ServiceName + "-" + getBackendNameV1(container) + "-" + serviceName) diff --git a/provider/docker/deprecated_service_test.go b/provider/docker/deprecated_service_test.go index 9d955b1dc..50c0a404c 100644 --- a/provider/docker/deprecated_service_test.go +++ b/provider/docker/deprecated_service_test.go @@ -162,7 +162,7 @@ func TestDockerServiceBuildConfigurationV1(t *testing.T) { "traefik.service.port": "2503", "traefik.service.protocol": "https", "traefik.service.weight": "80", - "traefik.service.frontend.backend": "foobar", + "traefik.service.backend": "foobar", "traefik.service.frontend.passHostHeader": "false", "traefik.service.frontend.rule": "Path:/mypath", "traefik.service.frontend.priority": "5000", @@ -595,7 +595,7 @@ func TestDockerGetServiceBackendNameV1(t *testing.T) { }, { container: containerJSON(labels(map[string]string{ - "traefik.myservice.frontend.backend": "custom-backend", + "traefik.myservice.backend": "custom-backend", })), expected: "fake-custom-backend", }, diff --git a/provider/label/label.go b/provider/label/label.go index 71f9e1a64..87bf950f8 100644 --- a/provider/label/label.go +++ b/provider/label/label.go @@ -27,11 +27,6 @@ const ( DefaultBackendMaxconnExtractorFunc = "request.host" DefaultBackendLoadbalancerStickinessCookieName = "" DefaultBackendHealthCheckPort = 0 - - // TODO need to be remove in extra-service-fabric - DefaultWeightInt = 1 // Deprecated - DefaultPassHostHeaderBool = true // Deprecated - DefaultFrontendPriorityInt = 0 // Deprecated ) var ( @@ -64,6 +59,7 @@ func GetBoolValue(labels map[string]string, labelName string, defaultValue bool) if err == nil { return v } + log.Errorf("Unable to parse %q: %q, falling back to %v. %v", labelName, rawValue, defaultValue, err) } return defaultValue } diff --git a/provider/label/names.go b/provider/label/names.go index ae0aaaede..e23f9a087 100644 --- a/provider/label/names.go +++ b/provider/label/names.go @@ -32,7 +32,6 @@ const ( SuffixBackendBufferingRetryExpression = SuffixBackendBuffering + ".retryExpression" SuffixFrontend = "frontend" SuffixFrontendAuthBasic = "frontend.auth.basic" - SuffixFrontendBackend = "frontend.backend" SuffixFrontendEntryPoints = "frontend.entryPoints" SuffixFrontendHeaders = "frontend.headers." SuffixFrontendRequestHeaders = SuffixFrontendHeaders + "customRequestHeaders" @@ -98,7 +97,6 @@ const ( TraefikBackendBufferingRetryExpression = Prefix + SuffixBackendBufferingRetryExpression TraefikFrontend = Prefix + SuffixFrontend TraefikFrontendAuthBasic = Prefix + SuffixFrontendAuthBasic - TraefikFrontendBackend = Prefix + SuffixFrontendBackend TraefikFrontendEntryPoints = Prefix + SuffixFrontendEntryPoints TraefikFrontendPassHostHeader = Prefix + SuffixFrontendPassHostHeader TraefikFrontendPassTLSCert = Prefix + SuffixFrontendPassTLSCert diff --git a/provider/rancher/config.go b/provider/rancher/config.go index 6b59ca9fd..255850fe6 100644 --- a/provider/rancher/config.go +++ b/provider/rancher/config.go @@ -150,7 +150,7 @@ func getBackendName(service rancherData) string { } func getSegmentBackendName(service rancherData) string { - if value := label.GetStringValue(service.SegmentLabels, label.TraefikFrontendBackend, ""); len(value) > 0 { + if value := label.GetStringValue(service.SegmentLabels, label.TraefikBackend, ""); len(value) > 0 { return provider.Normalize(service.Name + "-" + value) }