From 567387aee073af53e3b70c0d86f2d95649993877 Mon Sep 17 00:00:00 2001 From: Lewis Headden Date: Tue, 22 Nov 2016 10:11:28 -0500 Subject: [PATCH] Enable TCP Keep Alive for Marathon Client and make value configurable (#784) * Resolve rebase conflicts * Fix imports that VSCode messed up --- configuration.go | 1 + docs/toml.md | 6 ++++++ provider/marathon.go | 6 ++++-- traefik.sample.toml | 7 +++++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/configuration.go b/configuration.go index 19130349a..6754d67e8 100644 --- a/configuration.go +++ b/configuration.go @@ -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 diff --git a/docs/toml.md b/docs/toml.md index 4ccdbb2a8..ed5db1687 100644 --- a/docs/toml.md +++ b/docs/toml.md @@ -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: diff --git a/provider/marathon.go b/provider/marathon.go index 117ac8158..f7960e4c4 100644 --- a/provider/marathon.go +++ b/provider/marathon.go @@ -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) diff --git a/traefik.sample.toml b/traefik.sample.toml index 0ac52b7e7..e1c45b82a 100644 --- a/traefik.sample.toml +++ b/traefik.sample.toml @@ -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 ################################################################