1
0
Fork 0

Server weight zero

This commit is contained in:
Ludovic Fernandez 2018-04-11 16:30:04 +02:00 committed by Traefiker Bot
parent edbcd01fbc
commit 8168d2fdc1
84 changed files with 378 additions and 273 deletions

View file

@ -116,9 +116,9 @@ func TestFiller(t *testing.T) {
{Key: "traefik/backends/backend.with.dot.too/servers", Value: []byte("")},
{Key: "traefik/backends/backend.with.dot.too/servers/server.with.dot", Value: []byte("")},
{Key: "traefik/backends/backend.with.dot.too/servers/server.with.dot.without.url", Value: []byte("")},
{Key: "traefik/backends/backend.with.dot.too/servers/server.with.dot.without.url/weight", Value: []byte("0")},
{Key: "traefik/backends/backend.with.dot.too/servers/server.with.dot.without.url/weight", Value: []byte("1")},
{Key: "traefik/backends/backend.with.dot.too/servers/server.with.dot/url", Value: []byte("http://172.17.0.2:80")},
{Key: "traefik/backends/backend.with.dot.too/servers/server.with.dot/weight", Value: []byte("0")},
{Key: "traefik/backends/backend.with.dot.too/servers/server.with.dot/weight", Value: []byte("1")},
{Key: "traefik/frontends/frontend.with.dot", Value: []byte("")},
{Key: "traefik/frontends/frontend.with.dot/backend", Value: []byte("backend.with.dot.too")},
{Key: "traefik/frontends/frontend.with.dot/errors", Value: []byte("")},
@ -157,8 +157,8 @@ func TestFiller(t *testing.T) {
withLimit("bar", "3", "6", "9"))),
backend("backend.with.dot.too",
withPair("servers/server.with.dot/url", "http://172.17.0.2:80"),
withPair("servers/server.with.dot/weight", "0"),
withPair("servers/server.with.dot.without.url/weight", "0")),
withPair("servers/server.with.dot/weight", "1"),
withPair("servers/server.with.dot.without.url/weight", "1")),
)
assert.EqualValues(t, expected, pairs1)
@ -181,8 +181,8 @@ func TestFiller(t *testing.T) {
withPair("ratelimit/rateset/bar/period", "9")),
entry("backends/backend.with.dot.too",
withPair("servers/server.with.dot/url", "http://172.17.0.2:80"),
withPair("servers/server.with.dot/weight", "0"),
withPair("servers/server.with.dot.without.url/weight", "0")),
withPair("servers/server.with.dot/weight", "1"),
withPair("servers/server.with.dot.without.url/weight", "1")),
)
assert.EqualValues(t, expected, pairs2)
}

View file

@ -42,7 +42,7 @@ func (p *Provider) buildConfiguration() *types.Configuration {
// Frontend functions
"getBackendName": p.getFuncString(pathFrontendBackend, ""),
"getPriority": p.getFuncInt(pathFrontendPriority, label.DefaultFrontendPriorityInt),
"getPriority": p.getFuncInt(pathFrontendPriority, label.DefaultFrontendPriority),
"getPassHostHeader": p.getPassHostHeader(),
"getPassTLSCert": p.getFuncBool(pathFrontendPassTLSCert, label.DefaultPassTLSCert),
"getEntryPoints": p.getFuncList(pathFrontendEntryPoints),
@ -89,12 +89,12 @@ func (p *Provider) getPassHostHeader() func(rootPath string) bool {
value, err := strconv.ParseBool(rawValue)
if err != nil {
log.Errorf("Invalid value for %s %s: %s", rootPath, pathFrontendPassHostHeader, rawValue)
return label.DefaultPassHostHeaderBool
return label.DefaultPassHostHeader
}
return value
}
return p.getBool(label.DefaultPassHostHeaderBool, rootPath, pathFrontendPassHostHeaderDeprecated)
return p.getBool(label.DefaultPassHostHeader, rootPath, pathFrontendPassHostHeaderDeprecated)
}
}
@ -402,7 +402,7 @@ func (p *Provider) getServers(rootPath string) map[string]types.Server {
serverName := p.last(serverKey)
servers[serverName] = types.Server{
URL: serverURL,
Weight: p.getInt(0, serverKey, pathBackendServerWeight),
Weight: p.getInt(label.DefaultWeight, serverKey, pathBackendServerWeight),
}
}

View file

@ -32,8 +32,8 @@ func TestProviderBuildConfiguration(t *testing.T) {
withPair("routes/route.with.dot/rule", "Host:test.localhost")),
backend("backend.with.dot.too",
withPair("servers/server.with.dot/url", "http://172.17.0.2:80"),
withPair("servers/server.with.dot/weight", "0"),
withPair("servers/server.with.dot.without.url/weight", "0")),
withPair("servers/server.with.dot/weight", strconv.Itoa(label.DefaultWeight)),
withPair("servers/server.with.dot.without.url/weight", strconv.Itoa(label.DefaultWeight))),
),
expected: &types.Configuration{
Backends: map[string]*types.Backend{
@ -42,7 +42,7 @@ func TestProviderBuildConfiguration(t *testing.T) {
Servers: map[string]types.Server{
"server.with.dot": {
URL: "http://172.17.0.2:80",
Weight: 0,
Weight: label.DefaultWeight,
},
},
},
@ -82,8 +82,8 @@ func TestProviderBuildConfiguration(t *testing.T) {
withPair(pathBackendBufferingMemRequestBodyBytes, "2097152"),
withPair(pathBackendBufferingRetryExpression, "IsNetworkError() && Attempts() <= 2"),
withPair("servers/server1/url", "http://172.17.0.2:80"),
withPair("servers/server1/weight", "0"),
withPair("servers/server2/weight", "0")),
withPair("servers/server1/weight", strconv.Itoa(label.DefaultWeight)),
withPair("servers/server2/weight", strconv.Itoa(label.DefaultWeight))),
frontend("frontend1",
withPair(pathFrontendBackend, "backend1"),
withPair(pathFrontendPriority, "6"),
@ -148,7 +148,7 @@ func TestProviderBuildConfiguration(t *testing.T) {
Servers: map[string]types.Server{
"server1": {
URL: "http://172.17.0.2:80",
Weight: 0,
Weight: label.DefaultWeight,
},
},
CircuitBreaker: &types.CircuitBreaker{
@ -2012,7 +2012,7 @@ func TestProviderGetServers(t *testing.T) {
expected: map[string]types.Server{
"server1": {
URL: "http://172.17.0.2:80",
Weight: 0,
Weight: label.DefaultWeight,
},
},
},
@ -2027,7 +2027,7 @@ func TestProviderGetServers(t *testing.T) {
expected: map[string]types.Server{
"server1": {
URL: "http://172.17.0.2:80",
Weight: 0,
Weight: label.DefaultWeight,
},
"server2": {
URL: "http://172.17.0.3:80",