consul/kv.tmpl: weight default value should be a int (#826)

* consul/kv.tmpl: weight default value should be a int

Fix #821

* Use 0 as default weight in all backends
This commit is contained in:
Kristian Klausen 2016-11-23 14:49:55 +01:00 committed by Emile Vauge
parent fe1b982d13
commit a8cb905255
8 changed files with 34 additions and 34 deletions

View file

@ -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",
},
}

View file

@ -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 {

View file

@ -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,

View file

@ -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,
}
}
}

View file

@ -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,

View file

@ -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,

View file

@ -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}}

View file

@ -32,7 +32,7 @@
{{range $servers}}
[backends."{{Last $backend}}".servers."{{Last .}}"]
url = "{{Get "" . "/url"}}"
weight = {{Get "" . "/weight"}}
weight = {{Get "0" . "/weight"}}
{{end}}
{{end}}