diff --git a/Gopkg.lock b/Gopkg.lock index 5e000b6b0..84234b255 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -255,10 +255,10 @@ revision = "4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9" [[projects]] - branch = "master" name = "github.com/cenk/backoff" packages = ["."] - revision = "2ea60e5f094469f9e65adb9cd103795b73ae743e" + revision = "1e4cf3da559842a91afcb6ea6141451e6c30c618" + version = "v2.1.1" [[projects]] name = "github.com/cenkalti/backoff" @@ -308,8 +308,8 @@ [[projects]] name = "github.com/containous/traefik-extra-service-fabric" packages = ["."] - revision = "6e90a9eef2ac9d320e55d6e994d169673a8d8b0f" - version = "v1.3.0" + revision = "b9142ccc2205284b288c0b085444fedd42ea5126" + version = "v1.4.0" [[projects]] name = "github.com/coreos/bbolt" @@ -1904,6 +1904,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "7234505a1c5efade68c571b94aded09899e8c5888d3f4af16928d88e8797c887" + inputs-digest = "8e2d1952c8e853cc6514e5962809e746f0f20eda9dce49e5f17a1d35544fc79e" solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index 913e76268..252469c8e 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -71,7 +71,7 @@ [[constraint]] name = "github.com/containous/traefik-extra-service-fabric" - version = "1.3.0" + version = "1.4.0" [[constraint]] name = "github.com/coreos/go-systemd" diff --git a/docs/configuration/backends/servicefabric.md b/docs/configuration/backends/servicefabric.md index 65a4700ec..563849dd5 100644 --- a/docs/configuration/backends/servicefabric.md +++ b/docs/configuration/backends/servicefabric.md @@ -96,11 +96,12 @@ Labels, set through extensions or the property manager, can be used on services | Label | Description | |------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `traefik.enable=false` | Disable this container in Traefik | +| `traefik.enable=false` | Disable this container in Traefik | | `traefik.backend.circuitbreaker.expression=EXPR` | Create a [circuit breaker](/basics/#backends) to be used against the backend | -| `traefik.servicefabric.groupname` | Group all services with the same name into a single backend in Traefik | -| `traefik.servicefabric.groupweight` | Set the weighting of the current services nodes in the backend group | -| `traefik.servicefabric.enablelabeloverrides` | Toggle whether labels can be overridden using the Service Fabric Property Manager API | +| `traefik.servicefabric.groupname` | Group all services with the same name into a single backend in Traefik | +| `traefik.servicefabric.groupweight` | Set the weighting of the current services nodes in the backend group | +| `traefik.servicefabric.enablelabeloverrides` | Toggle whether labels can be overridden using the Service Fabric Property Manager API | +| `traefik.servicefabric.endpointname` | Specify the name of the endpoint | | `traefik.backend.healthcheck.path=/health` | Enable health check for the backend, hitting the container at `path`. | | `traefik.backend.healthcheck.port=8080` | Allow to use a different port for the health check. | | `traefik.backend.healthcheck.interval=1s` | Define the health check interval. | diff --git a/vendor/github.com/cenk/backoff/context.go b/vendor/github.com/cenk/backoff/context.go index 5d1570925..7706faa2b 100644 --- a/vendor/github.com/cenk/backoff/context.go +++ b/vendor/github.com/cenk/backoff/context.go @@ -1,9 +1,8 @@ package backoff import ( + "context" "time" - - "golang.org/x/net/context" ) // BackOffContext is a backoff policy that stops retrying after the context @@ -52,9 +51,13 @@ func (b *backOffContext) Context() context.Context { func (b *backOffContext) NextBackOff() time.Duration { select { - case <-b.Context().Done(): + case <-b.ctx.Done(): return Stop default: - return b.BackOff.NextBackOff() } + next := b.BackOff.NextBackOff() + if deadline, ok := b.ctx.Deadline(); ok && deadline.Sub(time.Now()) < next { + return Stop + } + return next } diff --git a/vendor/github.com/cenk/backoff/exponential.go b/vendor/github.com/cenk/backoff/exponential.go index d9de15a17..a031a6597 100644 --- a/vendor/github.com/cenk/backoff/exponential.go +++ b/vendor/github.com/cenk/backoff/exponential.go @@ -63,7 +63,6 @@ type ExponentialBackOff struct { currentInterval time.Duration startTime time.Time - random *rand.Rand } // Clock is an interface that returns current time for BackOff. @@ -89,7 +88,6 @@ func NewExponentialBackOff() *ExponentialBackOff { MaxInterval: DefaultMaxInterval, MaxElapsedTime: DefaultMaxElapsedTime, Clock: SystemClock, - random: rand.New(rand.NewSource(time.Now().UnixNano())), } b.Reset() return b @@ -118,10 +116,7 @@ func (b *ExponentialBackOff) NextBackOff() time.Duration { return Stop } defer b.incrementCurrentInterval() - if b.random == nil { - b.random = rand.New(rand.NewSource(time.Now().UnixNano())) - } - return getRandomValueFromInterval(b.RandomizationFactor, b.random.Float64(), b.currentInterval) + return getRandomValueFromInterval(b.RandomizationFactor, rand.Float64(), b.currentInterval) } // GetElapsedTime returns the elapsed time since an ExponentialBackOff instance diff --git a/vendor/github.com/cenk/backoff/retry.go b/vendor/github.com/cenk/backoff/retry.go index 5dbd825b5..e936a506f 100644 --- a/vendor/github.com/cenk/backoff/retry.go +++ b/vendor/github.com/cenk/backoff/retry.go @@ -15,7 +15,6 @@ type Notify func(error, time.Duration) // Retry the operation o until it does not return error or BackOff stops. // o is guaranteed to be run at least once. -// It is the caller's responsibility to reset b after Retry returns. // // If o returns a *PermanentError, the operation is not retried, and the // wrapped error is returned. @@ -29,6 +28,7 @@ func Retry(o Operation, b BackOff) error { return RetryNotify(o, b, nil) } func RetryNotify(operation Operation, b BackOff, notify Notify) error { var err error var next time.Duration + var t *time.Timer cb := ensureContext(b) @@ -42,7 +42,7 @@ func RetryNotify(operation Operation, b BackOff, notify Notify) error { return permanent.Err } - if next = b.NextBackOff(); next == Stop { + if next = cb.NextBackOff(); next == Stop { return err } @@ -50,11 +50,15 @@ func RetryNotify(operation Operation, b BackOff, notify Notify) error { notify(err, next) } - t := time.NewTimer(next) + if t == nil { + t = time.NewTimer(next) + defer t.Stop() + } else { + t.Reset(next) + } select { case <-cb.Context().Done(): - t.Stop() return err case <-t.C: } diff --git a/vendor/github.com/cenk/backoff/ticker.go b/vendor/github.com/cenk/backoff/ticker.go index e742512fd..e41084b0e 100644 --- a/vendor/github.com/cenk/backoff/ticker.go +++ b/vendor/github.com/cenk/backoff/ticker.go @@ -1,7 +1,6 @@ package backoff import ( - "runtime" "sync" "time" ) @@ -34,7 +33,6 @@ func NewTicker(b BackOff) *Ticker { } t.b.Reset() go t.run() - runtime.SetFinalizer(t, (*Ticker).Stop) return t } diff --git a/vendor/github.com/containous/traefik-extra-service-fabric/servicefabric.go b/vendor/github.com/containous/traefik-extra-service-fabric/servicefabric.go index bb7c3fb37..a425473e1 100644 --- a/vendor/github.com/containous/traefik-extra-service-fabric/servicefabric.go +++ b/vendor/github.com/containous/traefik-extra-service-fabric/servicefabric.go @@ -15,7 +15,7 @@ import ( "github.com/containous/traefik/provider/label" "github.com/containous/traefik/safe" "github.com/containous/traefik/types" - "github.com/jjcollinge/logrus-appinsights" + appinsights "github.com/jjcollinge/logrus-appinsights" sf "github.com/jjcollinge/servicefabric" ) @@ -164,11 +164,12 @@ func getClusterServices(sfClient sfClient) ([]ServiceItemExtended, error) { for _, partition := range partitions.Items { partitionExt := PartitionItemExtended{PartitionItem: partition} - if isStateful(item) { + switch { + case isStateful(item): partitionExt.Replicas = getValidReplicas(sfClient, app, service, partition) - } else if isStateless(item) { + case isStateless(item): partitionExt.Instances = getValidInstances(sfClient, app, service, partition) - } else { + default: log.Errorf("Unsupported service kind %s in service %s", partition.ServiceKind, service.Name) continue } @@ -291,7 +292,7 @@ func getLabels(sfClient sfClient, service *sf.ServiceItem, app *sf.ApplicationIt } func createAppInsightsHook(appInsightsClientName string, instrumentationKey string, maxBatchSize int, interval flaeg.Duration) { - hook, err := logrus_appinsights.New(appInsightsClientName, logrus_appinsights.Config{ + hook, err := appinsights.New(appInsightsClientName, appinsights.Config{ InstrumentationKey: instrumentationKey, MaxBatchSize: maxBatchSize, // optional MaxBatchInterval: time.Duration(interval), // optional diff --git a/vendor/github.com/containous/traefik-extra-service-fabric/servicefabric_tmpl.go b/vendor/github.com/containous/traefik-extra-service-fabric/servicefabric_tmpl.go index 524a3289b..cc7d3e7fb 100644 --- a/vendor/github.com/containous/traefik-extra-service-fabric/servicefabric_tmpl.go +++ b/vendor/github.com/containous/traefik-extra-service-fabric/servicefabric_tmpl.go @@ -8,8 +8,13 @@ const tmpl = ` {{range $partition := $service.Partitions }} {{range $instance := $partition.Instances }} [backends."{{ $aggName }}".servers."{{ $service.ID }}-{{ $instance.ID }}"] - url = "{{ getDefaultEndpoint $instance }}" weight = {{ getGroupedWeight $service }} + {{ $endpointName := getLabelValue $service "traefik.servicefabric.endpointname" "" }} + {{if $endpointName }} + url = "{{ getNamedEndpoint $instance $endpointName }}" + {{else}} + url = "{{ getDefaultEndpoint $instance }}" + {{end}} {{end}} {{end}} {{end}} @@ -65,8 +70,13 @@ const tmpl = ` {{range $instance := $partition.Instances}} [backends."{{ $service.Name }}".servers."{{ $instance.ID }}"] - url = "{{ getDefaultEndpoint $instance }}" weight = {{ getWeight $service }} + {{ $endpointName := getLabelValue $service "traefik.servicefabric.endpointname" "" }} + {{if $endpointName }} + url = "{{ getNamedEndpoint $instance $endpointName }}" + {{else}} + url = "{{ getDefaultEndpoint $instance }}" + {{end}} {{end}} {{else if isStateful $service}} @@ -75,11 +85,16 @@ const tmpl = ` {{if isPrimary $replica}} {{ $backendName := getBackendName $service $partition }} [backends."{{ $backendName }}".servers."{{ $replica.ID }}"] - url = "{{ getDefaultEndpoint $replica }}" - weight = 1 + weight = 1 + {{ $endpointName := getLabelValue $service "traefik.servicefabric.endpointname" "" }} + {{if $endpointName }} + url = "{{ getNamedEndpoint $replica $endpointName }}" + {{else}} + url = "{{ getDefaultEndpoint $replica }}" + {{end}} - [backends."{{$backendName}}".LoadBalancer] - method = "drr" + [backends."{{$backendName}}".LoadBalancer] + method = "drr" {{end}} {{end}} @@ -114,14 +129,14 @@ const tmpl = ` passHostHeader = {{ getPassHostHeader $service }} passTLSCert = {{ getPassTLSCert $service }} priority = {{ getPriority $service }} - + {{ $entryPoints := getEntryPoints $service }} {{if $entryPoints }} entryPoints = [{{range $entryPoints }} "{{.}}", {{end}}] {{end}} - + {{ $basicAuth := getBasicAuth $service }} {{if $basicAuth }} basicAuth = [{{range $basicAuth }} @@ -166,33 +181,33 @@ const tmpl = ` PublicKey = "{{ $headers.PublicKey }}" ReferrerPolicy = "{{ $headers.ReferrerPolicy }}" IsDevelopment = {{ $headers.IsDevelopment }} - + {{if $headers.AllowedHosts }} AllowedHosts = [{{range $headers.AllowedHosts }} "{{.}}", {{end}}] {{end}} - + {{if $headers.HostsProxyHeaders }} HostsProxyHeaders = [{{range $headers.HostsProxyHeaders }} "{{.}}", {{end}}] {{end}} - + {{if $headers.CustomRequestHeaders }} [frontends."frontend-{{ $frontendName }}".headers.customRequestHeaders] {{range $k, $v := $headers.CustomRequestHeaders }} {{$k}} = "{{$v}}" {{end}} {{end}} - + {{if $headers.CustomResponseHeaders }} [frontends."frontend-{{ $frontendName }}".headers.customResponseHeaders] {{range $k, $v := $headers.CustomResponseHeaders }} {{$k}} = "{{$v}}" {{end}} {{end}} - + {{if $headers.SSLProxyHeaders }} [frontends."frontend-{{ $frontendName }}".headers.SSLProxyHeaders] {{range $k, $v := $headers.SSLProxyHeaders }} @@ -200,7 +215,7 @@ const tmpl = ` {{end}} {{end}} {{end}} - + {{range $key, $value := getFrontendRules $service }} [frontends."frontend-{{ $frontendName }}".routes."{{ $key }}"] rule = "{{ $value }}"