Allow specification of dialertimeout

Address documentation comments
This commit is contained in:
Bruce Lee 2016-10-05 11:42:58 -04:00
parent 91e3bdff48
commit e068ee09ca
4 changed files with 30 additions and 7 deletions

View file

@ -325,6 +325,7 @@ func NewTraefikDefaultPointersConfiguration() *TraefikConfiguration {
defaultMarathon.Endpoint = "http://127.0.0.1:8080" defaultMarathon.Endpoint = "http://127.0.0.1:8080"
defaultMarathon.ExposedByDefault = true defaultMarathon.ExposedByDefault = true
defaultMarathon.Constraints = []types.Constraint{} defaultMarathon.Constraints = []types.Constraint{}
defaultMarathon.DialerTimeout = 60
// default Consul // default Consul
var defaultConsul provider.Consul var defaultConsul provider.Consul

View file

@ -836,6 +836,15 @@ domain = "marathon.localhost"
# Optional # Optional
# #
# dcosToken = "xxxxxx" # dcosToken = "xxxxxx"
# Override DialerTimeout
# Amount of time in seconds to allow the Marathon provider to wait to open a TCP
# connection to a Marathon master
#
# Optional
# Default: 60
# dialerTimeout = 5
``` ```
Labels can be used on containers to override default behaviour: Labels can be used on containers to override default behaviour:

View file

@ -2,6 +2,7 @@ package provider
import ( import (
"errors" "errors"
"net"
"net/url" "net/url"
"sort" "sort"
"strconv" "strconv"
@ -26,13 +27,14 @@ var _ Provider = (*Marathon)(nil)
// Marathon holds configuration of the Marathon provider. // Marathon holds configuration of the Marathon provider.
type Marathon struct { type Marathon struct {
BaseProvider BaseProvider
Endpoint string `description:"Marathon server endpoint. You can also specify multiple endpoint for Marathon"` Endpoint string `description:"Marathon server endpoint. You can also specify multiple endpoint for Marathon"`
Domain string `description:"Default domain used"` Domain string `description:"Default domain used"`
ExposedByDefault bool `description:"Expose Marathon apps by default"` ExposedByDefault bool `description:"Expose Marathon apps by default"`
GroupsAsSubDomains bool `description:"Convert Marathon groups to subdomains"` GroupsAsSubDomains bool `description:"Convert Marathon groups to subdomains"`
DCOSToken string `description:"DCOSToken for DCOS environment, This will override the Authorization header"` DCOSToken string `description:"DCOSToken for DCOS environment, This will override the Authorization header"`
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"`
Basic *MarathonBasic Basic *MarathonBasic
marathonClient marathon.Marathon marathonClient marathon.Marathon
} }
@ -70,6 +72,9 @@ func (provider *Marathon) Provide(configurationChan chan<- types.ConfigMessage,
config.HTTPClient = &http.Client{ config.HTTPClient = &http.Client{
Transport: &http.Transport{ Transport: &http.Transport{
TLSClientConfig: TLSConfig, TLSClientConfig: TLSConfig,
DialContext: (&net.Dialer{
Timeout: time.Second * provider.DialerTimeout,
}).DialContext,
}, },
} }
client, err := marathon.NewClient(config) client, err := marathon.NewClient(config)

View file

@ -487,6 +487,14 @@
# #
# groupsAsSubDomains = true # groupsAsSubDomains = true
# Override DialerTimeout
# Amount of time in seconds to allow the Marathon provider to wait to open a TCP
# connection to a Marathon master
#
# Optional
# Default: 60
# dialerTimeout = 5
# Enable Marathon basic authentication # Enable Marathon basic authentication
# #
# Optional # Optional