Fix deprecated IdleTimeout config
This commit is contained in:
parent
f9225c54ff
commit
52c1909f24
3 changed files with 42 additions and 32 deletions
|
@ -159,25 +159,42 @@ func NewTraefikDefaultPointersConfiguration() *TraefikConfiguration {
|
||||||
FilePath: "",
|
FilePath: "",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// default HealthCheckConfig
|
||||||
|
healthCheck := configuration.HealthCheckConfig{
|
||||||
|
Interval: flaeg.Duration(configuration.DefaultHealthCheckInterval),
|
||||||
|
}
|
||||||
|
|
||||||
|
// default RespondingTimeouts
|
||||||
|
respondingTimeouts := configuration.RespondingTimeouts{
|
||||||
|
IdleTimeout: flaeg.Duration(configuration.DefaultIdleTimeout),
|
||||||
|
}
|
||||||
|
|
||||||
|
// default ForwardingTimeouts
|
||||||
|
forwardingTimeouts := configuration.ForwardingTimeouts{
|
||||||
|
DialTimeout: flaeg.Duration(configuration.DefaultDialTimeout),
|
||||||
|
}
|
||||||
|
|
||||||
defaultConfiguration := configuration.GlobalConfiguration{
|
defaultConfiguration := configuration.GlobalConfiguration{
|
||||||
Docker: &defaultDocker,
|
Docker: &defaultDocker,
|
||||||
File: &defaultFile,
|
File: &defaultFile,
|
||||||
Web: &defaultWeb,
|
Web: &defaultWeb,
|
||||||
Marathon: &defaultMarathon,
|
Marathon: &defaultMarathon,
|
||||||
Consul: &defaultConsul,
|
Consul: &defaultConsul,
|
||||||
ConsulCatalog: &defaultConsulCatalog,
|
ConsulCatalog: &defaultConsulCatalog,
|
||||||
Etcd: &defaultEtcd,
|
Etcd: &defaultEtcd,
|
||||||
Zookeeper: &defaultZookeeper,
|
Zookeeper: &defaultZookeeper,
|
||||||
Boltdb: &defaultBoltDb,
|
Boltdb: &defaultBoltDb,
|
||||||
Kubernetes: &defaultKubernetes,
|
Kubernetes: &defaultKubernetes,
|
||||||
Mesos: &defaultMesos,
|
Mesos: &defaultMesos,
|
||||||
ECS: &defaultECS,
|
ECS: &defaultECS,
|
||||||
Rancher: &defaultRancher,
|
Rancher: &defaultRancher,
|
||||||
Eureka: &defaultEureka,
|
Eureka: &defaultEureka,
|
||||||
DynamoDB: &defaultDynamoDB,
|
DynamoDB: &defaultDynamoDB,
|
||||||
Retry: &configuration.Retry{},
|
Retry: &configuration.Retry{},
|
||||||
HealthCheck: &configuration.HealthCheckConfig{},
|
HealthCheck: &healthCheck,
|
||||||
AccessLog: &defaultAccessLog,
|
AccessLog: &defaultAccessLog,
|
||||||
|
RespondingTimeouts: &respondingTimeouts,
|
||||||
|
ForwardingTimeouts: &forwardingTimeouts,
|
||||||
}
|
}
|
||||||
|
|
||||||
return &TraefikConfiguration{
|
return &TraefikConfiguration{
|
||||||
|
@ -202,12 +219,6 @@ func NewTraefikConfiguration() *TraefikConfiguration {
|
||||||
HealthCheck: &configuration.HealthCheckConfig{
|
HealthCheck: &configuration.HealthCheckConfig{
|
||||||
Interval: flaeg.Duration(configuration.DefaultHealthCheckInterval),
|
Interval: flaeg.Duration(configuration.DefaultHealthCheckInterval),
|
||||||
},
|
},
|
||||||
RespondingTimeouts: &configuration.RespondingTimeouts{
|
|
||||||
IdleTimeout: flaeg.Duration(configuration.DefaultIdleTimeout),
|
|
||||||
},
|
|
||||||
ForwardingTimeouts: &configuration.ForwardingTimeouts{
|
|
||||||
DialTimeout: flaeg.Duration(configuration.DefaultDialTimeout),
|
|
||||||
},
|
|
||||||
CheckNewVersion: true,
|
CheckNewVersion: true,
|
||||||
},
|
},
|
||||||
ConfigFile: "",
|
ConfigFile: "",
|
||||||
|
|
|
@ -127,7 +127,7 @@ func NewServer(globalConfiguration configuration.GlobalConfiguration) *Server {
|
||||||
// behaviour and backwards compatibility issues.
|
// behaviour and backwards compatibility issues.
|
||||||
func createHTTPTransport(globalConfiguration configuration.GlobalConfiguration) *http.Transport {
|
func createHTTPTransport(globalConfiguration configuration.GlobalConfiguration) *http.Transport {
|
||||||
dialer := &net.Dialer{
|
dialer := &net.Dialer{
|
||||||
Timeout: 30 * time.Second,
|
Timeout: configuration.DefaultDialTimeout,
|
||||||
KeepAlive: 30 * time.Second,
|
KeepAlive: 30 * time.Second,
|
||||||
DualStack: true,
|
DualStack: true,
|
||||||
}
|
}
|
||||||
|
@ -675,14 +675,13 @@ func buildServerTimeouts(globalConfig configuration.GlobalConfiguration) (readTi
|
||||||
writeTimeout = time.Duration(globalConfig.RespondingTimeouts.WriteTimeout)
|
writeTimeout = time.Duration(globalConfig.RespondingTimeouts.WriteTimeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
// When RespondingTimeouts.IdleTimout is configured, always use that setting
|
// Prefer legacy idle timeout parameter for backwards compatibility reasons
|
||||||
if globalConfig.RespondingTimeouts != nil {
|
if globalConfig.IdleTimeout > 0 {
|
||||||
idleTimeout = time.Duration(globalConfig.RespondingTimeouts.IdleTimeout)
|
|
||||||
} else if globalConfig.IdleTimeout != 0 {
|
|
||||||
// Backwards compatibility for deprecated IdleTimeout
|
|
||||||
idleTimeout = time.Duration(globalConfig.IdleTimeout)
|
idleTimeout = time.Duration(globalConfig.IdleTimeout)
|
||||||
|
log.Warn("top-level idle timeout configuration has been deprecated -- please use responding timeouts")
|
||||||
|
} else if globalConfig.RespondingTimeouts != nil {
|
||||||
|
idleTimeout = time.Duration(globalConfig.RespondingTimeouts.IdleTimeout)
|
||||||
} else {
|
} else {
|
||||||
// Default value if neither the deprecated IdleTimeout nor the new RespondingTimeouts.IdleTimout are configured
|
|
||||||
idleTimeout = time.Duration(configuration.DefaultIdleTimeout)
|
idleTimeout = time.Duration(configuration.DefaultIdleTimeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ func TestPrepareServerTimeouts(t *testing.T) {
|
||||||
IdleTimeout: flaeg.Duration(80 * time.Second),
|
IdleTimeout: flaeg.Duration(80 * time.Second),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
wantIdleTimeout: time.Duration(80 * time.Second),
|
wantIdleTimeout: time.Duration(45 * time.Second),
|
||||||
wantReadTimeout: time.Duration(0 * time.Second),
|
wantReadTimeout: time.Duration(0 * time.Second),
|
||||||
wantWriteTimeout: time.Duration(0 * time.Second),
|
wantWriteTimeout: time.Duration(0 * time.Second),
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue