1
0
Fork 0

Add health check timeout parameter

This commit is contained in:
Jared Biel 2018-09-27 13:16:03 -05:00 committed by Traefiker Bot
parent f10516deb7
commit 5acd43efaf
45 changed files with 189 additions and 28 deletions

View file

@ -7,6 +7,7 @@ const (
pathBackendHealthCheckPath = "/healthcheck/path"
pathBackendHealthCheckPort = "/healthcheck/port"
pathBackendHealthCheckInterval = "/healthcheck/interval"
pathBackendHealthCheckTimeout = "/healthcheck/timeout"
pathBackendHealthCheckHostname = "/healthcheck/hostname"
pathBackendHealthCheckHeaders = "/healthcheck/headers/"
pathBackendLoadBalancerMethod = "/loadbalancer/method"

View file

@ -271,6 +271,7 @@ func (p *Provider) getHealthCheck(rootPath string) *types.HealthCheck {
scheme := p.get("", rootPath, pathBackendHealthCheckScheme)
port := p.getInt(label.DefaultBackendHealthCheckPort, rootPath, pathBackendHealthCheckPort)
interval := p.get("30s", rootPath, pathBackendHealthCheckInterval)
timeout := p.get("5s", rootPath, pathBackendHealthCheckTimeout)
hostname := p.get("", rootPath, pathBackendHealthCheckHostname)
headers := p.getMap(rootPath, pathBackendHealthCheckHeaders)
@ -279,6 +280,7 @@ func (p *Provider) getHealthCheck(rootPath string) *types.HealthCheck {
Path: path,
Port: port,
Interval: interval,
Timeout: timeout,
Hostname: hostname,
Headers: headers,
}

View file

@ -260,6 +260,7 @@ func TestProviderBuildConfiguration(t *testing.T) {
withPair(pathBackendHealthCheckPath, "/health"),
withPair(pathBackendHealthCheckPort, "80"),
withPair(pathBackendHealthCheckInterval, "30s"),
withPair(pathBackendHealthCheckTimeout, "5s"),
withPair(pathBackendHealthCheckHostname, "foo.com"),
withPair(pathBackendHealthCheckHeaders+"Foo", "bar"),
withPair(pathBackendHealthCheckHeaders+"Bar", "foo"),
@ -387,6 +388,7 @@ func TestProviderBuildConfiguration(t *testing.T) {
Path: "/health",
Port: 80,
Interval: "30s",
Timeout: "5s",
Hostname: "foo.com",
Headers: map[string]string{
"Foo": "bar",
@ -1986,9 +1988,12 @@ func TestProviderGetHealthCheck(t *testing.T) {
backend("foo",
withPair(pathBackendHealthCheckPath, "/health"),
withPair(pathBackendHealthCheckPort, "80"),
withPair(pathBackendHealthCheckInterval, "10s"))),
withPair(pathBackendHealthCheckInterval, "10s"),
withPair(pathBackendHealthCheckTimeout, "3s"))),
expected: &types.HealthCheck{
Interval: "10s",
Timeout: "3s",
Path: "/health",
Port: 80,
},
@ -2001,6 +2006,7 @@ func TestProviderGetHealthCheck(t *testing.T) {
withPair(pathBackendHealthCheckPath, "/health"))),
expected: &types.HealthCheck{
Interval: "30s",
Timeout: "5s",
Path: "/health",
Port: 0,
},
@ -2011,7 +2017,8 @@ func TestProviderGetHealthCheck(t *testing.T) {
kvPairs: filler("traefik",
backend("foo",
withPair(pathBackendHealthCheckPort, "80"),
withPair(pathBackendHealthCheckInterval, "30s"))),
withPair(pathBackendHealthCheckInterval, "30s"),
withPair(pathBackendHealthCheckTimeout, "5s"))),
expected: nil,
},
}