Enable TCP Keep Alive for Marathon Client and make value configurable (#784)

* Resolve rebase conflicts

* Fix imports that VSCode messed up
This commit is contained in:
Lewis Headden 2016-11-22 10:11:28 -05:00 committed by Emile Vauge
parent 15732269da
commit 567387aee0
4 changed files with 18 additions and 2 deletions

View file

@ -327,6 +327,7 @@ func NewTraefikDefaultPointersConfiguration() *TraefikConfiguration {
defaultMarathon.ExposedByDefault = true
defaultMarathon.Constraints = []types.Constraint{}
defaultMarathon.DialerTimeout = 60
defaultMarathon.KeepAlive = 10
// default Consul
var defaultConsul provider.Consul

View file

@ -845,6 +845,12 @@ domain = "marathon.localhost"
# Default: 60
# dialerTimeout = 5
# Set the TCP Keep Alive interval (in seconds) for the Marathon HTTP Client
#
# Optional
# Default: 10
#
# keepAlive = 10
```
Labels can be used on containers to override default behaviour:

View file

@ -35,6 +35,7 @@ type Marathon struct {
MarathonLBCompatibility bool `description:"Add compatibility with marathon-lb labels"`
TLS *ClientTLS `description:"Enable Docker TLS support"`
DialerTimeout time.Duration `description:"Set a non-default connection timeout for Marathon"`
KeepAlive time.Duration `description:"Set a non-default TCP Keep Alive time in seconds"`
Basic *MarathonBasic
marathonClient marathon.Marathon
}
@ -71,10 +72,11 @@ func (provider *Marathon) Provide(configurationChan chan<- types.ConfigMessage,
}
config.HTTPClient = &http.Client{
Transport: &http.Transport{
TLSClientConfig: TLSConfig,
DialContext: (&net.Dialer{
Timeout: time.Second * provider.DialerTimeout,
KeepAlive: provider.KeepAlive * time.Second,
Timeout: time.Second * provider.DialerTimeout,
}).DialContext,
TLSClientConfig: TLSConfig,
},
}
client, err := marathon.NewClient(config)

View file

@ -510,6 +510,13 @@
# dcosToken = "xxxxxx"
# Set the TCP Keep Alive interval (in seconds) for the Marathon HTTP Client
#
# Optional
# Default: 10
#
# keepAlive = 10
################################################################
# Mesos configuration backend
################################################################