diff --git a/provider/consul_catalog_test.go b/provider/consul_catalog_test.go index d6d41207d..789aa432d 100644 --- a/provider/consul_catalog_test.go +++ b/provider/consul_catalog_test.go @@ -61,7 +61,7 @@ func TestConsulCatalogGetAttribute(t *testing.T) { "traefik.backend.weight=42", }, key: "backend.weight", - defaultValue: "", + defaultValue: "0", expected: "42", }, { @@ -70,8 +70,8 @@ func TestConsulCatalogGetAttribute(t *testing.T) { "traefik.backend.wei=42", }, key: "backend.weight", - defaultValue: "", - expected: "", + defaultValue: "0", + expected: "0", }, } diff --git a/provider/docker.go b/provider/docker.go index e2b312044..ec91044f6 100644 --- a/provider/docker.go +++ b/provider/docker.go @@ -455,7 +455,7 @@ func (provider *Docker) getWeight(container dockerData) string { if label, err := getLabel(container, "traefik.weight"); err == nil { return label } - return "1" + return "0" } func (provider *Docker) getSticky(container dockerData) string { diff --git a/provider/docker_test.go b/provider/docker_test.go index 1873c5d56..43fbcb5e4 100644 --- a/provider/docker_test.go +++ b/provider/docker_test.go @@ -436,7 +436,7 @@ func TestDockerGetWeight(t *testing.T) { }, Config: &container.Config{}, }, - expected: "1", + expected: "0", }, { container: docker.ContainerJSON{ @@ -972,7 +972,7 @@ func TestDockerLoadDockerConfig(t *testing.T) { Servers: map[string]types.Server{ "server-test": { URL: "http://127.0.0.1:80", - Weight: 1, + Weight: 0, }, }, CircuitBreaker: nil, @@ -1054,11 +1054,11 @@ func TestDockerLoadDockerConfig(t *testing.T) { Servers: map[string]types.Server{ "server-test1": { URL: "http://127.0.0.1:80", - Weight: 1, + Weight: 0, }, "server-test2": { URL: "http://127.0.0.1:80", - Weight: 1, + Weight: 0, }, }, CircuitBreaker: nil, @@ -1112,7 +1112,7 @@ func TestDockerLoadDockerConfig(t *testing.T) { Servers: map[string]types.Server{ "server-test1": { URL: "http://127.0.0.1:80", - Weight: 1, + Weight: 0, }, }, CircuitBreaker: &types.CircuitBreaker{ @@ -1527,7 +1527,7 @@ func TestSwarmGetWeight(t *testing.T) { }, }, }, - expected: "1", + expected: "0", networks: map[string]*docker.NetworkResource{}, }, { @@ -2055,7 +2055,7 @@ func TestSwarmLoadDockerConfig(t *testing.T) { Servers: map[string]types.Server{ "server-test": { URL: "http://127.0.0.1:80", - Weight: 1, + Weight: 0, }, }, CircuitBreaker: nil, @@ -2143,11 +2143,11 @@ func TestSwarmLoadDockerConfig(t *testing.T) { Servers: map[string]types.Server{ "server-test1": { URL: "http://127.0.0.1:80", - Weight: 1, + Weight: 0, }, "server-test2": { URL: "http://127.0.0.1:80", - Weight: 1, + Weight: 0, }, }, CircuitBreaker: nil, diff --git a/provider/kubernetes.go b/provider/kubernetes.go index a08014eff..546dbe564 100644 --- a/provider/kubernetes.go +++ b/provider/kubernetes.go @@ -262,7 +262,7 @@ func (provider *Kubernetes) loadIngresses(k8sClient k8s.Client) (*types.Configur log.Warnf("Endpoints not found for %s/%s, falling back to Service ClusterIP", service.ObjectMeta.Namespace, service.ObjectMeta.Name) templateObjects.Backends[r.Host+pa.Path].Servers[string(service.UID)] = types.Server{ URL: protocol + "://" + service.Spec.ClusterIP + ":" + strconv.Itoa(port.Port), - Weight: 1, + Weight: 0, } } else { for _, subset := range endpoints.Subsets { @@ -274,7 +274,7 @@ func (provider *Kubernetes) loadIngresses(k8sClient k8s.Client) (*types.Configur } templateObjects.Backends[r.Host+pa.Path].Servers[name] = types.Server{ URL: url, - Weight: 1, + Weight: 0, } } } diff --git a/provider/kubernetes_test.go b/provider/kubernetes_test.go index 2a4e935f9..e450b4934 100644 --- a/provider/kubernetes_test.go +++ b/provider/kubernetes_test.go @@ -204,11 +204,11 @@ func TestLoadIngresses(t *testing.T) { Servers: map[string]types.Server{ "http://10.10.0.1:8080": { URL: "http://10.10.0.1:8080", - Weight: 1, + Weight: 0, }, "http://10.21.0.1:8080": { URL: "http://10.21.0.1:8080", - Weight: 1, + Weight: 0, }, }, CircuitBreaker: nil, @@ -218,15 +218,15 @@ func TestLoadIngresses(t *testing.T) { Servers: map[string]types.Server{ "2": { URL: "http://10.0.0.2:802", - Weight: 1, + Weight: 0, }, "https://10.15.0.1:8443": { URL: "https://10.15.0.1:8443", - Weight: 1, + Weight: 0, }, "https://10.15.0.2:9443": { URL: "https://10.15.0.2:9443", - Weight: 1, + Weight: 0, }, }, CircuitBreaker: nil, @@ -556,7 +556,7 @@ func TestGetPassHostHeader(t *testing.T) { Servers: map[string]types.Server{ "1": { URL: "http://10.0.0.1:801", - Weight: 1, + Weight: 0, }, }, CircuitBreaker: nil, @@ -665,7 +665,7 @@ func TestOnlyReferencesServicesFromOwnNamespace(t *testing.T) { Servers: map[string]types.Server{ "1": { URL: "http://10.0.0.1:80", - Weight: 1, + Weight: 0, }, }, CircuitBreaker: nil, @@ -851,7 +851,7 @@ func TestLoadNamespacedIngresses(t *testing.T) { Servers: map[string]types.Server{ "1": { URL: "http://10.0.0.1:801", - Weight: 1, + Weight: 0, }, }, CircuitBreaker: nil, @@ -861,11 +861,11 @@ func TestLoadNamespacedIngresses(t *testing.T) { Servers: map[string]types.Server{ "2": { URL: "http://10.0.0.2:802", - Weight: 1, + Weight: 0, }, "3": { URL: "https://10.0.0.3:443", - Weight: 1, + Weight: 0, }, }, CircuitBreaker: nil, @@ -1089,7 +1089,7 @@ func TestLoadMultipleNamespacedIngresses(t *testing.T) { Servers: map[string]types.Server{ "1": { URL: "http://10.0.0.1:801", - Weight: 1, + Weight: 0, }, }, CircuitBreaker: nil, @@ -1099,11 +1099,11 @@ func TestLoadMultipleNamespacedIngresses(t *testing.T) { Servers: map[string]types.Server{ "2": { URL: "http://10.0.0.2:802", - Weight: 1, + Weight: 0, }, "3": { URL: "https://10.0.0.3:443", - Weight: 1, + Weight: 0, }, }, CircuitBreaker: nil, @@ -1113,7 +1113,7 @@ func TestLoadMultipleNamespacedIngresses(t *testing.T) { Servers: map[string]types.Server{ "17": { URL: "http://10.0.0.4:801", - Weight: 1, + Weight: 0, }, }, CircuitBreaker: nil, @@ -1227,7 +1227,7 @@ func TestHostlessIngress(t *testing.T) { Servers: map[string]types.Server{ "1": { URL: "http://10.0.0.1:801", - Weight: 1, + Weight: 0, }, }, CircuitBreaker: nil, diff --git a/provider/kv_test.go b/provider/kv_test.go index 3e1502529..e0913b110 100644 --- a/provider/kv_test.go +++ b/provider/kv_test.go @@ -408,7 +408,7 @@ func TestKVLoadConfig(t *testing.T) { }, { Key: "traefik/backends/backend.with.dot.too/servers/server.with.dot/weight", - Value: []byte("1"), + Value: []byte("0"), }, }, }, @@ -420,7 +420,7 @@ func TestKVLoadConfig(t *testing.T) { Servers: map[string]types.Server{ "server.with.dot": { URL: "http://172.17.0.2:80", - Weight: 1, + Weight: 0, }, }, CircuitBreaker: nil, diff --git a/templates/consul_catalog.tmpl b/templates/consul_catalog.tmpl index 546132c81..b47f82a17 100644 --- a/templates/consul_catalog.tmpl +++ b/templates/consul_catalog.tmpl @@ -3,7 +3,7 @@ {{if ne (getAttribute "enable" $node.Service.Tags "true") "false"}} [backends."backend-{{getBackend $node}}".servers."{{getBackendName $node $index}}"] url = "{{getAttribute "protocol" $node.Service.Tags "http"}}://{{getBackendAddress $node}}:{{$node.Service.Port}}" - {{$weight := getAttribute "backend.weight" $node.Service.Tags ""}} + {{$weight := getAttribute "backend.weight" $node.Service.Tags "0"}} {{with $weight}} weight = {{$weight}} {{end}} diff --git a/templates/kv.tmpl b/templates/kv.tmpl index c642ff7b1..333a63653 100644 --- a/templates/kv.tmpl +++ b/templates/kv.tmpl @@ -32,7 +32,7 @@ {{range $servers}} [backends."{{Last $backend}}".servers."{{Last .}}"] url = "{{Get "" . "/url"}}" - weight = {{Get "" . "/weight"}} + weight = {{Get "0" . "/weight"}} {{end}} {{end}}