From 48e7a87741a41c6506b884b94434fe4f9345148b Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Fri, 7 Sep 2018 09:40:03 +0200 Subject: [PATCH] Update go version --- CONTRIBUTING.md | 2 +- Gopkg.lock | 2 +- anonymize/anonymize_config_test.go | 28 +++++----- build.Dockerfile | 2 +- cmd/bug/bug.go | 2 +- cmd/healthcheck/healthcheck.go | 2 +- configuration/entrypoints_test.go | 26 ++++----- healthcheck/healthcheck.go | 2 +- middlewares/accesslog/logger_test.go | 56 +++++++++---------- middlewares/ip_whitelister.go | 2 +- middlewares/retry.go | 2 +- provider/ecs/ecs.go | 2 +- provider/kubernetes/kubernetes_test.go | 24 ++++---- provider/mesos/mesos.go | 2 +- provider/rancher/config_test.go | 2 +- provider/rancher/deprecated_config_test.go | 2 +- provider/rancher/metadata.go | 4 +- .../github.com/vulcand/oxy/buffer/buffer.go | 11 +++- 18 files changed, 90 insertions(+), 83 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1f6a4ac5e..980f06153 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -13,7 +13,7 @@ You need to run the `binary` target. This will create binaries for Linux platfor $ make binary docker build -t "traefik-dev:no-more-godep-ever" -f build.Dockerfile . Sending build context to Docker daemon 295.3 MB -Step 0 : FROM golang:1.10-alpine +Step 0 : FROM golang:1.11-alpine ---> 8c6473912976 Step 1 : RUN go get github.com/golang/dep/cmd/dep [...] diff --git a/Gopkg.lock b/Gopkg.lock index 358d7c263..e0b9792e7 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -1272,7 +1272,7 @@ "roundrobin", "utils" ] - revision = "f6bbeac6d5c4c06f88ba07ed42983ff36a5b407e" + revision = "77148e9694210e5f5610328f1cd7cf65583014c2" [[projects]] name = "github.com/vulcand/predicate" diff --git a/anonymize/anonymize_config_test.go b/anonymize/anonymize_config_test.go index bb5975e4e..3ffe72bce 100644 --- a/anonymize/anonymize_config_test.go +++ b/anonymize/anonymize_config_test.go @@ -213,7 +213,7 @@ func TestDo_globalConfiguration(t *testing.T) { MustMatch: true, }, }, - Trace: true, + Trace: true, DebugLogGeneratedTemplate: true, }, Endpoint: "docker Endpoint", @@ -244,7 +244,7 @@ func TestDo_globalConfiguration(t *testing.T) { MustMatch: true, }, }, - Trace: true, + Trace: true, DebugLogGeneratedTemplate: true, }, Directory: "file Directory", @@ -309,7 +309,7 @@ func TestDo_globalConfiguration(t *testing.T) { MustMatch: true, }, }, - Trace: true, + Trace: true, DebugLogGeneratedTemplate: true, }, Endpoint: "", @@ -349,7 +349,7 @@ func TestDo_globalConfiguration(t *testing.T) { MustMatch: true, }, }, - Trace: true, + Trace: true, DebugLogGeneratedTemplate: true, }, Endpoint: "ConsulCatalog Endpoint", @@ -374,7 +374,7 @@ func TestDo_globalConfiguration(t *testing.T) { MustMatch: true, }, }, - Trace: true, + Trace: true, DebugLogGeneratedTemplate: true, }, Endpoint: "k8s Endpoint", @@ -400,7 +400,7 @@ func TestDo_globalConfiguration(t *testing.T) { MustMatch: true, }, }, - Trace: true, + Trace: true, DebugLogGeneratedTemplate: true, }, Endpoint: "mesos Endpoint", @@ -429,7 +429,7 @@ func TestDo_globalConfiguration(t *testing.T) { MustMatch: true, }, }, - Trace: true, + Trace: true, DebugLogGeneratedTemplate: true, }, Endpoint: "eureka Endpoint", @@ -452,7 +452,7 @@ func TestDo_globalConfiguration(t *testing.T) { MustMatch: true, }, }, - Trace: true, + Trace: true, DebugLogGeneratedTemplate: true, }, Domain: "ecs Domain", @@ -481,7 +481,7 @@ func TestDo_globalConfiguration(t *testing.T) { MustMatch: true, }, }, - Trace: true, + Trace: true, DebugLogGeneratedTemplate: true, }, APIConfiguration: rancher.APIConfiguration{ @@ -519,7 +519,7 @@ func TestDo_globalConfiguration(t *testing.T) { MustMatch: true, }, }, - Trace: true, + Trace: true, DebugLogGeneratedTemplate: true, }, AccessKeyID: "dynamodb AccessKeyID", @@ -546,7 +546,7 @@ func TestDo_globalConfiguration(t *testing.T) { MustMatch: true, }, }, - Trace: true, + Trace: true, DebugLogGeneratedTemplate: true, }, Endpoint: "etcd Endpoint", @@ -578,7 +578,7 @@ func TestDo_globalConfiguration(t *testing.T) { MustMatch: true, }, }, - Trace: true, + Trace: true, DebugLogGeneratedTemplate: true, }, Endpoint: "zk Endpoint", @@ -610,7 +610,7 @@ func TestDo_globalConfiguration(t *testing.T) { MustMatch: true, }, }, - Trace: true, + Trace: true, DebugLogGeneratedTemplate: true, }, Endpoint: "boltdb Endpoint", @@ -642,7 +642,7 @@ func TestDo_globalConfiguration(t *testing.T) { MustMatch: true, }, }, - Trace: true, + Trace: true, DebugLogGeneratedTemplate: true, }, Endpoint: "consul Endpoint", diff --git a/build.Dockerfile b/build.Dockerfile index 99d8a67d2..d7a279b5d 100644 --- a/build.Dockerfile +++ b/build.Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.10-alpine +FROM golang:1.11-alpine RUN apk --update upgrade \ && apk --no-cache --no-progress add git mercurial bash gcc musl-dev curl tar \ diff --git a/cmd/bug/bug.go b/cmd/bug/bug.go index 08e00133a..851f2296c 100644 --- a/cmd/bug/bug.go +++ b/cmd/bug/bug.go @@ -94,7 +94,7 @@ func NewCmd(traefikConfiguration *cmd.TraefikConfiguration, traefikPointersConfi Description: `Report an issue on Traefik bugtracker`, Config: traefikConfiguration, DefaultPointersConfig: traefikPointersConfiguration, - Run: runCmd(traefikConfiguration), + Run: runCmd(traefikConfiguration), Metadata: map[string]string{ "parseAllSources": "true", }, diff --git a/cmd/healthcheck/healthcheck.go b/cmd/healthcheck/healthcheck.go index 5acad5035..c395dfb34 100644 --- a/cmd/healthcheck/healthcheck.go +++ b/cmd/healthcheck/healthcheck.go @@ -20,7 +20,7 @@ func NewCmd(traefikConfiguration *cmd.TraefikConfiguration, traefikPointersConfi Description: `Calls traefik /ping to check health (web provider must be enabled)`, Config: traefikConfiguration, DefaultPointersConfig: traefikPointersConfiguration, - Run: runCmd(traefikConfiguration), + Run: runCmd(traefikConfiguration), Metadata: map[string]string{ "parseAllSources": "true", }, diff --git a/configuration/entrypoints_test.go b/configuration/entrypoints_test.go index ae4d88a6c..2ef6a5003 100644 --- a/configuration/entrypoints_test.go +++ b/configuration/entrypoints_test.go @@ -67,19 +67,19 @@ func Test_parseEntryPointsConfiguration(t *testing.T) { "ca_optional": "true", "compress": "true", "forwardedheaders_trustedips": "10.0.0.3/24,20.0.0.3/24", - "name": "foo", - "proxyprotocol_trustedips": "192.168.0.1", - "redirect_entrypoint": "https", - "redirect_permanent": "true", - "redirect_regex": "http://localhost/(.*)", - "redirect_replacement": "http://mydomain/$1", - "tls": "goo,gii", - "tls_acme": "TLS", - "tls_ciphersuites": "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA384,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", - "tls_minversion": "VersionTLS11", - "whitelistsourcerange": "10.42.0.0/16,152.89.1.33/32,afed:be44::/16", - "whitelist_sourcerange": "10.42.0.0/16,152.89.1.33/32,afed:be44::/16", - "whitelist_usexforwardedfor": "true", + "name": "foo", + "proxyprotocol_trustedips": "192.168.0.1", + "redirect_entrypoint": "https", + "redirect_permanent": "true", + "redirect_regex": "http://localhost/(.*)", + "redirect_replacement": "http://mydomain/$1", + "tls": "goo,gii", + "tls_acme": "TLS", + "tls_ciphersuites": "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA384,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", + "tls_minversion": "VersionTLS11", + "whitelistsourcerange": "10.42.0.0/16,152.89.1.33/32,afed:be44::/16", + "whitelist_sourcerange": "10.42.0.0/16,152.89.1.33/32,afed:be44::/16", + "whitelist_usexforwardedfor": "true", }, }, { diff --git a/healthcheck/healthcheck.go b/healthcheck/healthcheck.go index f24ba8766..8a6e9bba0 100644 --- a/healthcheck/healthcheck.go +++ b/healthcheck/healthcheck.go @@ -118,7 +118,7 @@ func (hc *HealthCheck) execute(ctx context.Context, backend *BackendConfig) { for { select { case <-ctx.Done(): - log.Debug("Stopping current health check goroutines of backend: %s", backend.name) + log.Debugf("Stopping current health check goroutines of backend: %s", backend.name) return case <-ticker.C: log.Debugf("Refreshing health check for backend: %s", backend.name) diff --git a/middlewares/accesslog/logger_test.go b/middlewares/accesslog/logger_test.go index 0657cfffb..cbf1da5fc 100644 --- a/middlewares/accesslog/logger_test.go +++ b/middlewares/accesslog/logger_test.go @@ -192,28 +192,28 @@ func TestLoggerJSON(t *testing.T) { Format: JSONFormat, }, expected: map[string]func(t *testing.T, value interface{}){ - RequestHost: assertString(testHostname), - RequestAddr: assertString(testHostname), - RequestMethod: assertString(testMethod), - RequestPath: assertString(testPath), - RequestProtocol: assertString(testProto), - RequestPort: assertString("-"), - RequestLine: assertString(fmt.Sprintf("%s %s %s", testMethod, testPath, testProto)), - DownstreamStatus: assertFloat64(float64(testStatus)), - DownstreamStatusLine: assertString(fmt.Sprintf("%d ", testStatus)), - DownstreamContentSize: assertFloat64(float64(len(testContent))), - OriginContentSize: assertFloat64(float64(len(testContent))), - OriginStatus: assertFloat64(float64(testStatus)), - RequestRefererHeader: assertString(testReferer), - RequestUserAgentHeader: assertString(testUserAgent), - FrontendName: assertString(testFrontendName), - BackendURL: assertString(testBackendName), - ClientUsername: assertString(testUsername), - ClientHost: assertString(testHostname), - ClientPort: assertString(fmt.Sprintf("%d", testPort)), - ClientAddr: assertString(fmt.Sprintf("%s:%d", testHostname, testPort)), - "level": assertString("info"), - "msg": assertString(""), + RequestHost: assertString(testHostname), + RequestAddr: assertString(testHostname), + RequestMethod: assertString(testMethod), + RequestPath: assertString(testPath), + RequestProtocol: assertString(testProto), + RequestPort: assertString("-"), + RequestLine: assertString(fmt.Sprintf("%s %s %s", testMethod, testPath, testProto)), + DownstreamStatus: assertFloat64(float64(testStatus)), + DownstreamStatusLine: assertString(fmt.Sprintf("%d ", testStatus)), + DownstreamContentSize: assertFloat64(float64(len(testContent))), + OriginContentSize: assertFloat64(float64(len(testContent))), + OriginStatus: assertFloat64(float64(testStatus)), + RequestRefererHeader: assertString(testReferer), + RequestUserAgentHeader: assertString(testUserAgent), + FrontendName: assertString(testFrontendName), + BackendURL: assertString(testBackendName), + ClientUsername: assertString(testUsername), + ClientHost: assertString(testHostname), + ClientPort: assertString(fmt.Sprintf("%d", testPort)), + ClientAddr: assertString(fmt.Sprintf("%s:%d", testHostname, testPort)), + "level": assertString("info"), + "msg": assertString(""), "downstream_Content-Type": assertString("text/plain; charset=utf-8"), RequestCount: assertFloat64NotZero(), Duration: assertFloat64NotZero(), @@ -234,9 +234,9 @@ func TestLoggerJSON(t *testing.T) { }, }, expected: map[string]func(t *testing.T, value interface{}){ - "level": assertString("info"), - "msg": assertString(""), - "time": assertNotEqual(""), + "level": assertString("info"), + "msg": assertString(""), + "time": assertNotEqual(""), "downstream_Content-Type": assertString("text/plain; charset=utf-8"), RequestRefererHeader: assertString(testReferer), RequestUserAgentHeader: assertString(testUserAgent), @@ -273,9 +273,9 @@ func TestLoggerJSON(t *testing.T) { }, }, expected: map[string]func(t *testing.T, value interface{}){ - "level": assertString("info"), - "msg": assertString(""), - "time": assertNotEqual(""), + "level": assertString("info"), + "msg": assertString(""), + "time": assertNotEqual(""), "downstream_Content-Type": assertString("REDACTED"), RequestRefererHeader: assertString("REDACTED"), RequestUserAgentHeader: assertString("REDACTED"), diff --git a/middlewares/ip_whitelister.go b/middlewares/ip_whitelister.go index a352aad12..578286b95 100644 --- a/middlewares/ip_whitelister.go +++ b/middlewares/ip_whitelister.go @@ -45,7 +45,7 @@ func (wl *IPWhiteLister) handle(w http.ResponseWriter, r *http.Request, next htt return } - tracing.SetErrorAndDebugLog(r, "request %+v matched white list %s - passing", r, wl.whiteLister) + tracing.SetErrorAndDebugLog(r, "request %+v matched white list %v - passing", r, wl.whiteLister) next.ServeHTTP(w, r) } diff --git a/middlewares/retry.go b/middlewares/retry.go index 57c631ded..ed9f339d9 100644 --- a/middlewares/retry.go +++ b/middlewares/retry.go @@ -126,7 +126,7 @@ func (rr *retryResponseWriterWithoutCloseNotify) Header() http.Header { func (rr *retryResponseWriterWithoutCloseNotify) Write(buf []byte) (int, error) { if rr.ShouldRetry() { - return 0, nil + return len(buf), nil } return rr.responseWriter.Write(buf) } diff --git a/provider/ecs/ecs.go b/provider/ecs/ecs.go index 15a90ddc2..96642e3ff 100644 --- a/provider/ecs/ecs.go +++ b/provider/ecs/ecs.go @@ -386,7 +386,7 @@ func (p *Provider) lookupEc2Instances(ctx context.Context, client *awsClient, cl }) if err != nil { - log.Errorf("Unable to describe instances [%s]: %v", err) + log.Errorf("Unable to describe instances: %v", err) return nil, err } } diff --git a/provider/kubernetes/kubernetes_test.go b/provider/kubernetes/kubernetes_test.go index b4595eb68..754e21841 100644 --- a/provider/kubernetes/kubernetes_test.go +++ b/provider/kubernetes/kubernetes_test.go @@ -517,37 +517,37 @@ func TestModifierType(t *testing.T) { expectedModifierRule string }{ { - desc: "Request modifier annotation missing", + desc: "Request modifier annotation missing", requestModifierAnnotation: "", expectedModifierRule: "", }, { - desc: "AddPrefix modifier annotation", + desc: "AddPrefix modifier annotation", requestModifierAnnotation: " AddPrefix: /foo", expectedModifierRule: "AddPrefix:/foo", }, { - desc: "ReplacePath modifier annotation", + desc: "ReplacePath modifier annotation", requestModifierAnnotation: " ReplacePath: /foo", expectedModifierRule: "ReplacePath:/foo", }, { - desc: "ReplacePathRegex modifier annotation", + desc: "ReplacePathRegex modifier annotation", requestModifierAnnotation: " ReplacePathRegex: /foo /bar", expectedModifierRule: "ReplacePathRegex:/foo /bar", }, { - desc: "AddPrefix modifier annotation", + desc: "AddPrefix modifier annotation", requestModifierAnnotation: "AddPrefix:/foo", expectedModifierRule: "AddPrefix:/foo", }, { - desc: "ReplacePath modifier annotation", + desc: "ReplacePath modifier annotation", requestModifierAnnotation: "ReplacePath:/foo", expectedModifierRule: "ReplacePath:/foo", }, { - desc: "ReplacePathRegex modifier annotation", + desc: "ReplacePathRegex modifier annotation", requestModifierAnnotation: "ReplacePathRegex:/foo /bar", expectedModifierRule: "ReplacePathRegex:/foo /bar", }, @@ -609,23 +609,23 @@ func TestModifierFails(t *testing.T) { requestModifierAnnotation string }{ { - desc: "Request modifier missing part of annotation", + desc: "Request modifier missing part of annotation", requestModifierAnnotation: "AddPrefix: ", }, { - desc: "Request modifier full of spaces annotation", + desc: "Request modifier full of spaces annotation", requestModifierAnnotation: " ", }, { - desc: "Request modifier missing both parts of annotation", + desc: "Request modifier missing both parts of annotation", requestModifierAnnotation: " : ", }, { - desc: "Request modifier using unknown rule", + desc: "Request modifier using unknown rule", requestModifierAnnotation: "Foo: /bar", }, { - desc: "Missing Rule", + desc: "Missing Rule", requestModifierAnnotation: " : /bar", }, } diff --git a/provider/mesos/mesos.go b/provider/mesos/mesos.go index 85a8beaaf..4f44040f2 100644 --- a/provider/mesos/mesos.go +++ b/provider/mesos/mesos.go @@ -128,7 +128,7 @@ func (p *Provider) Provide(configurationChan chan<- types.ConfigMessage, pool *s func detectMasters(zk string, masters []string) <-chan []string { changed := make(chan []string, 1) if zk != "" { - log.Debugf("Starting master detector for ZK ", zk) + log.Debugf("Starting master detector for ZK %s", zk) if md, err := detector.New(zk); err != nil { log.Errorf("Failed to create master detector: %v", err) } else if err := md.Detect(detect.NewMasters(masters, changed)); err != nil { diff --git a/provider/rancher/config_test.go b/provider/rancher/config_test.go index a73150ed0..1a5f529fd 100644 --- a/provider/rancher/config_test.go +++ b/provider/rancher/config_test.go @@ -743,7 +743,7 @@ func TestProviderBuildConfiguration(t *testing.T) { func TestProviderServiceFilter(t *testing.T) { provider := &Provider{ - Domain: "rancher.localhost", + Domain: "rancher.localhost", EnableServiceHealthFilter: true, } diff --git a/provider/rancher/deprecated_config_test.go b/provider/rancher/deprecated_config_test.go index 6c92a889a..44988cb16 100644 --- a/provider/rancher/deprecated_config_test.go +++ b/provider/rancher/deprecated_config_test.go @@ -175,7 +175,7 @@ func TestProviderBuildConfigurationV1(t *testing.T) { func TestProviderServiceFilterV1(t *testing.T) { provider := &Provider{ - Domain: "rancher.localhost", + Domain: "rancher.localhost", EnableServiceHealthFilter: true, } diff --git a/provider/rancher/metadata.go b/provider/rancher/metadata.go index 76e91e550..0a54d96e4 100644 --- a/provider/rancher/metadata.go +++ b/provider/rancher/metadata.go @@ -29,7 +29,7 @@ func (p *Provider) metadataProvide(configurationChan chan<- types.ConfigMessage, operation := func() error { client, err := rancher.NewClientAndWait(metadataServiceURL) if err != nil { - log.Errorln("Failed to create Rancher metadata service client: %s", err) + log.Errorf("Failed to create Rancher metadata service client: %v", err) return err } @@ -38,7 +38,7 @@ func (p *Provider) metadataProvide(configurationChan chan<- types.ConfigMessage, stacks, err := client.GetStacks() if err != nil { - log.Errorf("Failed to query Rancher metadata service: %s", err) + log.Errorf("Failed to query Rancher metadata service: %v", err) return } diff --git a/vendor/github.com/vulcand/oxy/buffer/buffer.go b/vendor/github.com/vulcand/oxy/buffer/buffer.go index d2bbe40ce..68b387925 100644 --- a/vendor/github.com/vulcand/oxy/buffer/buffer.go +++ b/vendor/github.com/vulcand/oxy/buffer/buffer.go @@ -383,7 +383,14 @@ func (b *bufferWriter) Header() http.Header { } func (b *bufferWriter) Write(buf []byte) (int, error) { - return b.buffer.Write(buf) + length, err := b.buffer.Write(buf) + if err != nil { + // Since go1.11 (https://github.com/golang/go/commit/8f38f28222abccc505b9a1992deecfe3e2cb85de) + // if the writer returns an error, the reverse proxy panics + b.log.Error(err) + length = len(buf) + } + return length, nil } // WriteHeader sets rw.Code. @@ -410,7 +417,7 @@ func (b *bufferWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) { return conn, rw, err } b.log.Warningf("Upstream ResponseWriter of type %v does not implement http.Hijacker. Returning dummy channel.", reflect.TypeOf(b.responseWriter)) - return nil, nil, fmt.Errorf("The response writer that was wrapped in this proxy, does not implement http.Hijacker. It is of type: %v", reflect.TypeOf(b.responseWriter)) + return nil, nil, fmt.Errorf("the response writer wrapped in this proxy does not implement http.Hijacker. Its type is: %v”", reflect.TypeOf(b.responseWriter)) } // SizeErrHandler Size error handler