Add health check timeout parameter
This commit is contained in:
parent
f10516deb7
commit
5acd43efaf
45 changed files with 189 additions and 28 deletions
|
@ -410,6 +410,7 @@ func TestProviderBuildConfiguration(t *testing.T) {
|
|||
label.TraefikBackendHealthCheckScheme + "=http",
|
||||
label.TraefikBackendHealthCheckPort + "=880",
|
||||
label.TraefikBackendHealthCheckInterval + "=6",
|
||||
label.TraefikBackendHealthCheckTimeout + "=3",
|
||||
label.TraefikBackendHealthCheckHostname + "=foo.com",
|
||||
label.TraefikBackendHealthCheckHeaders + "=Foo:bar || Bar:foo",
|
||||
label.TraefikBackendLoadBalancerMethod + "=drr",
|
||||
|
@ -691,6 +692,7 @@ func TestProviderBuildConfiguration(t *testing.T) {
|
|||
Path: "/health",
|
||||
Port: 880,
|
||||
Interval: "6",
|
||||
Timeout: "3",
|
||||
Hostname: "foo.com",
|
||||
Headers: map[string]string{
|
||||
"Foo": "bar",
|
||||
|
|
|
@ -437,6 +437,7 @@ func TestDockerBuildConfiguration(t *testing.T) {
|
|||
label.TraefikBackendHealthCheckPath: "/health",
|
||||
label.TraefikBackendHealthCheckPort: "880",
|
||||
label.TraefikBackendHealthCheckInterval: "6",
|
||||
label.TraefikBackendHealthCheckTimeout: "3",
|
||||
label.TraefikBackendHealthCheckHostname: "foo.com",
|
||||
label.TraefikBackendHealthCheckHeaders: "Foo:bar || Bar:foo",
|
||||
label.TraefikBackendLoadBalancerMethod: "drr",
|
||||
|
@ -683,6 +684,7 @@ func TestDockerBuildConfiguration(t *testing.T) {
|
|||
Path: "/health",
|
||||
Port: 880,
|
||||
Interval: "6",
|
||||
Timeout: "3",
|
||||
Hostname: "foo.com",
|
||||
Headers: map[string]string{
|
||||
"Foo": "bar",
|
||||
|
|
|
@ -385,6 +385,7 @@ func TestSwarmBuildConfiguration(t *testing.T) {
|
|||
label.TraefikBackendHealthCheckPath: "/health",
|
||||
label.TraefikBackendHealthCheckPort: "880",
|
||||
label.TraefikBackendHealthCheckInterval: "6",
|
||||
label.TraefikBackendHealthCheckTimeout: "3",
|
||||
label.TraefikBackendHealthCheckHostname: "foo.com",
|
||||
label.TraefikBackendHealthCheckHeaders: "Foo:bar || Bar:foo",
|
||||
label.TraefikBackendLoadBalancerMethod: "drr",
|
||||
|
@ -600,6 +601,7 @@ func TestSwarmBuildConfiguration(t *testing.T) {
|
|||
Path: "/health",
|
||||
Port: 880,
|
||||
Interval: "6",
|
||||
Timeout: "3",
|
||||
Hostname: "foo.com",
|
||||
Headers: map[string]string{
|
||||
"Foo": "bar",
|
||||
|
|
|
@ -68,7 +68,8 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
ID("1"),
|
||||
dockerLabels(map[string]*string{
|
||||
label.TraefikBackendHealthCheckPath: aws.String("/health"),
|
||||
label.TraefikBackendHealthCheckInterval: aws.String("1s"),
|
||||
label.TraefikBackendHealthCheckInterval: aws.String("6s"),
|
||||
label.TraefikBackendHealthCheckTimeout: aws.String("3s"),
|
||||
}),
|
||||
iMachine(
|
||||
mState(ec2.InstanceStateNameRunning),
|
||||
|
@ -84,7 +85,8 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
"backend-instance": {
|
||||
HealthCheck: &types.HealthCheck{
|
||||
Path: "/health",
|
||||
Interval: "1s",
|
||||
Interval: "6s",
|
||||
Timeout: "3s",
|
||||
},
|
||||
Servers: map[string]types.Server{
|
||||
"server-instance-1": {
|
||||
|
@ -343,6 +345,7 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
label.TraefikBackendHealthCheckPath: aws.String("/health"),
|
||||
label.TraefikBackendHealthCheckPort: aws.String("880"),
|
||||
label.TraefikBackendHealthCheckInterval: aws.String("6"),
|
||||
label.TraefikBackendHealthCheckTimeout: aws.String("3"),
|
||||
label.TraefikBackendHealthCheckHostname: aws.String("foo.com"),
|
||||
label.TraefikBackendHealthCheckHeaders: aws.String("Foo:bar || Bar:foo"),
|
||||
label.TraefikBackendLoadBalancerMethod: aws.String("drr"),
|
||||
|
@ -470,6 +473,7 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
Path: "/health",
|
||||
Port: 880,
|
||||
Interval: "6",
|
||||
Timeout: "3",
|
||||
Hostname: "foo.com",
|
||||
Headers: map[string]string{
|
||||
"Foo": "bar",
|
||||
|
@ -633,6 +637,7 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
label.TraefikBackendHealthCheckPath: aws.String("/health"),
|
||||
label.TraefikBackendHealthCheckPort: aws.String("880"),
|
||||
label.TraefikBackendHealthCheckInterval: aws.String("6"),
|
||||
label.TraefikBackendHealthCheckTimeout: aws.String("3"),
|
||||
label.TraefikBackendHealthCheckHostname: aws.String("foo.com"),
|
||||
label.TraefikBackendHealthCheckHeaders: aws.String("Foo:bar || Bar:foo"),
|
||||
label.TraefikBackendLoadBalancerMethod: aws.String("drr"),
|
||||
|
@ -719,6 +724,7 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
label.TraefikBackendHealthCheckPath: aws.String("/health"),
|
||||
label.TraefikBackendHealthCheckPort: aws.String("880"),
|
||||
label.TraefikBackendHealthCheckInterval: aws.String("6"),
|
||||
label.TraefikBackendHealthCheckTimeout: aws.String("3"),
|
||||
label.TraefikBackendHealthCheckHostname: aws.String("bar.com"),
|
||||
label.TraefikBackendHealthCheckHeaders: aws.String("Foo:bar || Bar:foo"),
|
||||
label.TraefikBackendLoadBalancerMethod: aws.String("drr"),
|
||||
|
@ -822,6 +828,7 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
Path: "/health",
|
||||
Port: 880,
|
||||
Interval: "6",
|
||||
Timeout: "3",
|
||||
Hostname: "foo.com",
|
||||
Headers: map[string]string{
|
||||
"Foo": "bar",
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ const (
|
|||
SuffixBackendHealthCheckPath = "backend.healthcheck.path"
|
||||
SuffixBackendHealthCheckPort = "backend.healthcheck.port"
|
||||
SuffixBackendHealthCheckInterval = "backend.healthcheck.interval"
|
||||
SuffixBackendHealthCheckTimeout = "backend.healthcheck.timeout"
|
||||
SuffixBackendHealthCheckHostname = "backend.healthcheck.hostname"
|
||||
SuffixBackendHealthCheckHeaders = "backend.healthcheck.headers"
|
||||
SuffixBackendLoadBalancer = "backend.loadbalancer"
|
||||
|
@ -120,6 +121,7 @@ const (
|
|||
TraefikBackendHealthCheckPath = Prefix + SuffixBackendHealthCheckPath
|
||||
TraefikBackendHealthCheckPort = Prefix + SuffixBackendHealthCheckPort
|
||||
TraefikBackendHealthCheckInterval = Prefix + SuffixBackendHealthCheckInterval
|
||||
TraefikBackendHealthCheckTimeout = Prefix + SuffixBackendHealthCheckTimeout
|
||||
TraefikBackendHealthCheckHostname = Prefix + SuffixBackendHealthCheckHostname
|
||||
TraefikBackendHealthCheckHeaders = Prefix + SuffixBackendHealthCheckHeaders
|
||||
TraefikBackendLoadBalancer = Prefix + SuffixBackendLoadBalancer
|
||||
|
|
|
@ -342,6 +342,7 @@ func GetHealthCheck(labels map[string]string) *types.HealthCheck {
|
|||
scheme := GetStringValue(labels, TraefikBackendHealthCheckScheme, "")
|
||||
port := GetIntValue(labels, TraefikBackendHealthCheckPort, DefaultBackendHealthCheckPort)
|
||||
interval := GetStringValue(labels, TraefikBackendHealthCheckInterval, "")
|
||||
timeout := GetStringValue(labels, TraefikBackendHealthCheckTimeout, "")
|
||||
hostname := GetStringValue(labels, TraefikBackendHealthCheckHostname, "")
|
||||
headers := GetMapValue(labels, TraefikBackendHealthCheckHeaders)
|
||||
|
||||
|
@ -350,6 +351,7 @@ func GetHealthCheck(labels map[string]string) *types.HealthCheck {
|
|||
Path: path,
|
||||
Port: port,
|
||||
Interval: interval,
|
||||
Timeout: timeout,
|
||||
Hostname: hostname,
|
||||
Headers: headers,
|
||||
}
|
||||
|
|
|
@ -379,6 +379,7 @@ func TestGetHealthCheck(t *testing.T) {
|
|||
labels: map[string]string{
|
||||
TraefikBackendHealthCheckPort: "80",
|
||||
TraefikBackendHealthCheckInterval: "6",
|
||||
TraefikBackendHealthCheckTimeout: "3",
|
||||
},
|
||||
expected: nil,
|
||||
},
|
||||
|
@ -388,6 +389,7 @@ func TestGetHealthCheck(t *testing.T) {
|
|||
TraefikBackendHealthCheckPath: "/health",
|
||||
TraefikBackendHealthCheckPort: "80",
|
||||
TraefikBackendHealthCheckInterval: "6",
|
||||
TraefikBackendHealthCheckTimeout: "3",
|
||||
TraefikBackendHealthCheckHeaders: "Foo:bar || Goo:bir",
|
||||
TraefikBackendHealthCheckHostname: "traefik",
|
||||
TraefikBackendHealthCheckScheme: "http",
|
||||
|
@ -397,6 +399,7 @@ func TestGetHealthCheck(t *testing.T) {
|
|||
Path: "/health",
|
||||
Port: 80,
|
||||
Interval: "6",
|
||||
Timeout: "3",
|
||||
Hostname: "traefik",
|
||||
Headers: map[string]string{
|
||||
"Foo": "bar",
|
||||
|
|
|
@ -359,6 +359,7 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
withLabel(label.TraefikBackendHealthCheckPath, "/health"),
|
||||
withLabel(label.TraefikBackendHealthCheckPort, "880"),
|
||||
withLabel(label.TraefikBackendHealthCheckInterval, "6"),
|
||||
withLabel(label.TraefikBackendHealthCheckTimeout, "3"),
|
||||
withLabel(label.TraefikBackendHealthCheckHostname, "foo.com"),
|
||||
withLabel(label.TraefikBackendHealthCheckHeaders, "Foo:bar || Bar:foo"),
|
||||
|
||||
|
@ -603,6 +604,7 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
Path: "/health",
|
||||
Port: 880,
|
||||
Interval: "6",
|
||||
Timeout: "3",
|
||||
Hostname: "foo.com",
|
||||
Headers: map[string]string{
|
||||
"Foo": "bar",
|
||||
|
@ -779,6 +781,7 @@ func TestBuildConfigurationSegments(t *testing.T) {
|
|||
withLabel(label.TraefikBackendHealthCheckPath, "/health"),
|
||||
withLabel(label.TraefikBackendHealthCheckPort, "880"),
|
||||
withLabel(label.TraefikBackendHealthCheckInterval, "6"),
|
||||
withLabel(label.TraefikBackendHealthCheckTimeout, "3"),
|
||||
withLabel(label.TraefikBackendLoadBalancerMethod, "drr"),
|
||||
withLabel(label.TraefikBackendLoadBalancerStickiness, "true"),
|
||||
withLabel(label.TraefikBackendLoadBalancerStickinessCookieName, "chocolate"),
|
||||
|
@ -1017,6 +1020,7 @@ func TestBuildConfigurationSegments(t *testing.T) {
|
|||
Path: "/health",
|
||||
Port: 880,
|
||||
Interval: "6",
|
||||
Timeout: "3",
|
||||
},
|
||||
Buffering: &types.Buffering{
|
||||
MaxResponseBodyBytes: 10485760,
|
||||
|
|
|
@ -316,6 +316,7 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
withLabel(label.TraefikBackendHealthCheckPath, "/health"),
|
||||
withLabel(label.TraefikBackendHealthCheckPort, "880"),
|
||||
withLabel(label.TraefikBackendHealthCheckInterval, "6"),
|
||||
withLabel(label.TraefikBackendHealthCheckTimeout, "3"),
|
||||
withLabel(label.TraefikBackendHealthCheckHostname, "foo.com"),
|
||||
withLabel(label.TraefikBackendHealthCheckHeaders, "Foo:bar || Bar:foo"),
|
||||
|
||||
|
@ -563,6 +564,7 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
Path: "/health",
|
||||
Port: 880,
|
||||
Interval: "6",
|
||||
Timeout: "3",
|
||||
Hostname: "foo.com",
|
||||
Headers: map[string]string{
|
||||
"Foo": "bar",
|
||||
|
@ -696,6 +698,7 @@ func TestBuildConfigurationSegments(t *testing.T) {
|
|||
withLabel(label.TraefikBackendHealthCheckPath, "/health"),
|
||||
withLabel(label.TraefikBackendHealthCheckPort, "880"),
|
||||
withLabel(label.TraefikBackendHealthCheckInterval, "6"),
|
||||
withLabel(label.TraefikBackendHealthCheckTimeout, "3"),
|
||||
withLabel(label.TraefikBackendHealthCheckHostname, "foo.com"),
|
||||
withLabel(label.TraefikBackendHealthCheckHeaders, "Foo:bar || Bar:foo"),
|
||||
withLabel(label.TraefikBackendLoadBalancerMethod, "drr"),
|
||||
|
@ -940,6 +943,7 @@ func TestBuildConfigurationSegments(t *testing.T) {
|
|||
Path: "/health",
|
||||
Port: 880,
|
||||
Interval: "6",
|
||||
Timeout: "3",
|
||||
Hostname: "foo.com",
|
||||
Headers: map[string]string{
|
||||
"Bar": "foo",
|
||||
|
|
|
@ -45,6 +45,7 @@ func TestProviderBuildConfiguration(t *testing.T) {
|
|||
label.TraefikBackendHealthCheckPath: "/health",
|
||||
label.TraefikBackendHealthCheckPort: "880",
|
||||
label.TraefikBackendHealthCheckInterval: "6",
|
||||
label.TraefikBackendHealthCheckTimeout: "3",
|
||||
label.TraefikBackendHealthCheckHostname: "foo.com",
|
||||
label.TraefikBackendHealthCheckHeaders: "Foo:bar || Bar:foo",
|
||||
label.TraefikBackendLoadBalancerMethod: "drr",
|
||||
|
@ -295,6 +296,7 @@ func TestProviderBuildConfiguration(t *testing.T) {
|
|||
Path: "/health",
|
||||
Port: 880,
|
||||
Interval: "6",
|
||||
Timeout: "3",
|
||||
Hostname: "foo.com",
|
||||
Headers: map[string]string{
|
||||
"Foo": "bar",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue