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.ExposedByDefault = true
defaultMarathon.Constraints = []types.Constraint{} defaultMarathon.Constraints = []types.Constraint{}
defaultMarathon.DialerTimeout = 60 defaultMarathon.DialerTimeout = 60
defaultMarathon.KeepAlive = 10
// default Consul // default Consul
var defaultConsul provider.Consul var defaultConsul provider.Consul

View file

@ -845,6 +845,12 @@ domain = "marathon.localhost"
# Default: 60 # Default: 60
# dialerTimeout = 5 # 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: 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"` MarathonLBCompatibility bool `description:"Add compatibility with marathon-lb labels"`
TLS *ClientTLS `description:"Enable Docker TLS support"` TLS *ClientTLS `description:"Enable Docker TLS support"`
DialerTimeout time.Duration `description:"Set a non-default connection timeout for Marathon"` 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 Basic *MarathonBasic
marathonClient marathon.Marathon marathonClient marathon.Marathon
} }
@ -71,10 +72,11 @@ func (provider *Marathon) Provide(configurationChan chan<- types.ConfigMessage,
} }
config.HTTPClient = &http.Client{ config.HTTPClient = &http.Client{
Transport: &http.Transport{ Transport: &http.Transport{
TLSClientConfig: TLSConfig,
DialContext: (&net.Dialer{ DialContext: (&net.Dialer{
Timeout: time.Second * provider.DialerTimeout, KeepAlive: provider.KeepAlive * time.Second,
Timeout: time.Second * provider.DialerTimeout,
}).DialContext, }).DialContext,
TLSClientConfig: TLSConfig,
}, },
} }
client, err := marathon.NewClient(config) client, err := marathon.NewClient(config)

View file

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