From 8028c5a78796373be3d3f664055b8d31847a44c0 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Tue, 18 Sep 2018 12:37:33 -0700 Subject: [PATCH 1/5] Switch to go 1.11 Whitespace changes are caused by the fact that gofmt from go-1.11 uses a different heuristic as to how to format the file, making the source code that was OK for go-1.10 causing a warning with go-1.11. NOTE this whitespace change makes the gofmt from go-1.10 complain, so please upgrade your golang. [v2: regen pb files] Signed-off-by: Kir Kolyshkin (cherry picked from commit fd2d7f2ef925282e8cd2920efa253151749102ad) Signed-off-by: Sebastiaan van Stijn --- .circleci/config.yml | 2 +- Dockerfile | 2 +- api/api.pb.txt | 18 +++++++++--------- api/dispatcher.pb.go | 6 +++--- api/logbroker.pb.go | 6 +++--- api/raft.pb.go | 2 +- api/types.pb.go | 2 +- manager/scheduler/constraint_test.go | 2 +- manager/scheduler/nodeinfo.go | 4 ++-- protobuf/plugin/raftproxy/test/service.pb.go | 6 +++--- 10 files changed, 25 insertions(+), 25 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ff0660c5f0..c0fcf6dfc7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -11,7 +11,7 @@ jobs: # Needed to install go OS: linux ARCH: amd64 - GOVERSION: 1.10.3 + GOVERSION: 1.11 # Needed to install protoc PROTOC_VERSION: 3.6.1 diff --git a/Dockerfile b/Dockerfile index 1df47b9d16..fa099aa4f2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # NOTE(dperny): for some reason, alpine was giving me trouble -FROM golang:1.10.3-stretch +FROM golang:1.11.0-stretch RUN apt-get update && apt-get install -y make git unzip diff --git a/api/api.pb.txt b/api/api.pb.txt index 27aa683b42..7c94371b8b 100755 --- a/api/api.pb.txt +++ b/api/api.pb.txt @@ -2491,8 +2491,8 @@ file { label: LABEL_OPTIONAL type: TYPE_UINT32 options { - 65003: "os.FileMode" 65001: 0 + 65003: "os.FileMode" } json_name: "mode" } @@ -2646,8 +2646,8 @@ file { type: TYPE_MESSAGE type_name: ".google.protobuf.Duration" options { - 65011: 1 65001: 0 + 65011: 1 } json_name: "delay" } @@ -3090,8 +3090,8 @@ file { } } options { - 62023: "PublishMode" 62001: 0 + 62023: "PublishMode" } } } @@ -3790,8 +3790,8 @@ file { label: LABEL_OPTIONAL type: TYPE_UINT32 options { - 65003: "os.FileMode" 65001: 0 + 65003: "os.FileMode" } json_name: "mode" } @@ -4207,8 +4207,8 @@ file { } } options { - 62023: "NodeRole" 62001: 0 + 62023: "NodeRole" } } syntax: "proto3" @@ -8058,8 +8058,8 @@ file { type: TYPE_MESSAGE type_name: ".google.protobuf.Duration" options { - 65011: 1 65001: 0 + 65011: 1 } json_name: "period" } @@ -9106,11 +9106,11 @@ file { } } options { - 63017: 1 - 63020: 1 - 63018: 1 63001: 0 63002: 0 + 63017: 1 + 63018: 1 + 63020: 1 } } file { diff --git a/api/dispatcher.pb.go b/api/dispatcher.pb.go index cc443848de..f72d3d9995 100644 --- a/api/dispatcher.pb.go +++ b/api/dispatcher.pb.go @@ -1664,7 +1664,7 @@ func (p *raftProxyDispatcherServer) Session(r *SessionRequest, stream Dispatcher } streamWrapper := Dispatcher_SessionServerWrapper{ Dispatcher_SessionServer: stream, - ctx: ctx, + ctx: ctx, } return p.local.Session(r, streamWrapper) } @@ -1785,7 +1785,7 @@ func (p *raftProxyDispatcherServer) Tasks(r *TasksRequest, stream Dispatcher_Tas } streamWrapper := Dispatcher_TasksServerWrapper{ Dispatcher_TasksServer: stream, - ctx: ctx, + ctx: ctx, } return p.local.Tasks(r, streamWrapper) } @@ -1836,7 +1836,7 @@ func (p *raftProxyDispatcherServer) Assignments(r *AssignmentsRequest, stream Di } streamWrapper := Dispatcher_AssignmentsServerWrapper{ Dispatcher_AssignmentsServer: stream, - ctx: ctx, + ctx: ctx, } return p.local.Assignments(r, streamWrapper) } diff --git a/api/logbroker.pb.go b/api/logbroker.pb.go index b6231e941c..5456c85816 100644 --- a/api/logbroker.pb.go +++ b/api/logbroker.pb.go @@ -1335,7 +1335,7 @@ func (p *raftProxyLogsServer) SubscribeLogs(r *SubscribeLogsRequest, stream Logs } streamWrapper := Logs_SubscribeLogsServerWrapper{ Logs_SubscribeLogsServer: stream, - ctx: ctx, + ctx: ctx, } return p.local.SubscribeLogs(r, streamWrapper) } @@ -1458,7 +1458,7 @@ func (p *raftProxyLogBrokerServer) ListenSubscriptions(r *ListenSubscriptionsReq } streamWrapper := LogBroker_ListenSubscriptionsServerWrapper{ LogBroker_ListenSubscriptionsServer: stream, - ctx: ctx, + ctx: ctx, } return p.local.ListenSubscriptions(r, streamWrapper) } @@ -1509,7 +1509,7 @@ func (p *raftProxyLogBrokerServer) PublishLogs(stream LogBroker_PublishLogsServe } streamWrapper := LogBroker_PublishLogsServerWrapper{ LogBroker_PublishLogsServer: stream, - ctx: ctx, + ctx: ctx, } return p.local.PublishLogs(streamWrapper) } diff --git a/api/raft.pb.go b/api/raft.pb.go index 058b29450c..a32a6001b9 100644 --- a/api/raft.pb.go +++ b/api/raft.pb.go @@ -1746,7 +1746,7 @@ func (p *raftProxyRaftServer) StreamRaftMessage(stream Raft_StreamRaftMessageSer } streamWrapper := Raft_StreamRaftMessageServerWrapper{ Raft_StreamRaftMessageServer: stream, - ctx: ctx, + ctx: ctx, } return p.local.StreamRaftMessage(streamWrapper) } diff --git a/api/types.pb.go b/api/types.pb.go index f41d5e2033..f5843467cb 100644 --- a/api/types.pb.go +++ b/api/types.pb.go @@ -594,7 +594,7 @@ var MaybeEncryptedRecord_Algorithm_name = map[int32]string{ 2: "FERNET_AES_128_CBC", } var MaybeEncryptedRecord_Algorithm_value = map[string]int32{ - "NONE": 0, + "NONE": 0, "SECRETBOX_SALSA20_POLY1305": 1, "FERNET_AES_128_CBC": 2, } diff --git a/manager/scheduler/constraint_test.go b/manager/scheduler/constraint_test.go index 7bd378139e..04097c8d34 100644 --- a/manager/scheduler/constraint_test.go +++ b/manager/scheduler/constraint_test.go @@ -54,7 +54,7 @@ func setupEnv() { Addr: "186.17.9.41", }, }, - Tasks: make(map[string]*api.Task), + Tasks: make(map[string]*api.Task), ActiveTasksCountByService: make(map[string]int), } } diff --git a/manager/scheduler/nodeinfo.go b/manager/scheduler/nodeinfo.go index 3094402a58..8f1ad331b5 100644 --- a/manager/scheduler/nodeinfo.go +++ b/manager/scheduler/nodeinfo.go @@ -45,8 +45,8 @@ type NodeInfo struct { func newNodeInfo(n *api.Node, tasks map[string]*api.Task, availableResources api.Resources) NodeInfo { nodeInfo := NodeInfo{ - Node: n, - Tasks: make(map[string]*api.Task), + Node: n, + Tasks: make(map[string]*api.Task), ActiveTasksCountByService: make(map[string]int), AvailableResources: availableResources.Copy(), usedHostPorts: make(map[hostPortSpec]struct{}), diff --git a/protobuf/plugin/raftproxy/test/service.pb.go b/protobuf/plugin/raftproxy/test/service.pb.go index a2e36b343c..61ca52768e 100644 --- a/protobuf/plugin/raftproxy/test/service.pb.go +++ b/protobuf/plugin/raftproxy/test/service.pb.go @@ -1070,7 +1070,7 @@ func (p *raftProxyRouteGuideServer) ListFeatures(r *Rectangle, stream RouteGuide } streamWrapper := RouteGuide_ListFeaturesServerWrapper{ RouteGuide_ListFeaturesServer: stream, - ctx: ctx, + ctx: ctx, } return p.local.ListFeatures(r, streamWrapper) } @@ -1121,7 +1121,7 @@ func (p *raftProxyRouteGuideServer) RecordRoute(stream RouteGuide_RecordRouteSer } streamWrapper := RouteGuide_RecordRouteServerWrapper{ RouteGuide_RecordRouteServer: stream, - ctx: ctx, + ctx: ctx, } return p.local.RecordRoute(streamWrapper) } @@ -1178,7 +1178,7 @@ func (p *raftProxyRouteGuideServer) RouteChat(stream RouteGuide_RouteChatServer) } streamWrapper := RouteGuide_RouteChatServerWrapper{ RouteGuide_RouteChatServer: stream, - ctx: ctx, + ctx: ctx, } return p.local.RouteChat(streamWrapper) } From 26b47ab6f34db170dd5225b384672a17765dc47b Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 19 Aug 2019 21:22:58 +0200 Subject: [PATCH 2/5] Bump Golang 1.11.13 Signed-off-by: Sebastiaan van Stijn (cherry picked from commit daf87201f686710974b282d4c0b0c8422e55dac9) Signed-off-by: Sebastiaan van Stijn --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index fa099aa4f2..c6dc96f957 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # NOTE(dperny): for some reason, alpine was giving me trouble -FROM golang:1.11.0-stretch +FROM golang:1.11.13-stretch RUN apt-get update && apt-get install -y make git unzip From ace6803427caadadc5fa130a09f2c968d8dd23c7 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 19 Aug 2019 21:27:13 +0200 Subject: [PATCH 3/5] Bump Golang 1.12.9 Signed-off-by: Sebastiaan van Stijn (cherry picked from commit be528e80a841ae89e1bd7539201f12c4de496ab3) Signed-off-by: Sebastiaan van Stijn --- .circleci/config.yml | 2 +- Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c0fcf6dfc7..7ab18ff408 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -11,7 +11,7 @@ jobs: # Needed to install go OS: linux ARCH: amd64 - GOVERSION: 1.11 + GOVERSION: 1.12 # Needed to install protoc PROTOC_VERSION: 3.6.1 diff --git a/Dockerfile b/Dockerfile index c6dc96f957..6d795a468b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # NOTE(dperny): for some reason, alpine was giving me trouble -FROM golang:1.11.13-stretch +FROM golang:1.12.9-stretch RUN apt-get update && apt-get install -y make git unzip From 2da1ccb80da73e8eb744ed03019b09ef82575a3a Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 19 Aug 2019 22:52:58 +0200 Subject: [PATCH 4/5] Update tests for new output with Go 1.12 Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 43fac9c8049f7dd2ae42d87f60d2a88f86f63853) Signed-off-by: Sebastiaan van Stijn --- template/getter_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/template/getter_test.go b/template/getter_test.go index a24fbfaa84..c2c1be0b22 100644 --- a/template/getter_test.go +++ b/template/getter_test.go @@ -160,7 +160,7 @@ func TestTemplatedSecret(t *testing.T) { Data: []byte("SECRET_VAL={{secret \"unknowntarget\"}}\n"), Templating: &api.Driver{Name: "golang"}, }, - expectedErr: `failed to expand templated secret templatedsecret: template: expansion:1:13: executing "expansion" at : error calling secret: secret target unknowntarget not found`, + expectedErr: `failed to expand templated secret templatedsecret: template: expansion:1:13: executing "expansion" at : error calling secret: secret target unknowntarget not found`, task: modifyTask(func(t *api.Task) { t.Spec = api.TaskSpec{ Runtime: &api.TaskSpec_Container{ @@ -185,7 +185,7 @@ func TestTemplatedSecret(t *testing.T) { Data: []byte("CONFIG_VAL={{config \"unknowntarget\"}}\n"), Templating: &api.Driver{Name: "golang"}, }, - expectedErr: `failed to expand templated secret templatedsecret: template: expansion:1:13: executing "expansion" at : error calling config: config target unknowntarget not found`, + expectedErr: `failed to expand templated secret templatedsecret: template: expansion:1:13: executing "expansion" at : error calling config: config target unknowntarget not found`, task: modifyTask(func(t *api.Task) { t.Spec = api.TaskSpec{ Runtime: &api.TaskSpec_Container{ @@ -440,7 +440,7 @@ func TestTemplatedConfig(t *testing.T) { Data: []byte("SECRET_VAL={{secret \"unknowntarget\"}}\n"), Templating: &api.Driver{Name: "golang"}, }, - expectedErr: `failed to expand templated config templatedconfig: template: expansion:1:13: executing "expansion" at : error calling secret: secret target unknowntarget not found`, + expectedErr: `failed to expand templated config templatedconfig: template: expansion:1:13: executing "expansion" at : error calling secret: secret target unknowntarget not found`, task: modifyTask(func(t *api.Task) { t.Spec = api.TaskSpec{ Runtime: &api.TaskSpec_Container{ @@ -465,7 +465,7 @@ func TestTemplatedConfig(t *testing.T) { Data: []byte("CONFIG_VAL={{config \"unknowntarget\"}}\n"), Templating: &api.Driver{Name: "golang"}, }, - expectedErr: `failed to expand templated config templatedconfig: template: expansion:1:13: executing "expansion" at : error calling config: config target unknowntarget not found`, + expectedErr: `failed to expand templated config templatedconfig: template: expansion:1:13: executing "expansion" at : error calling config: config target unknowntarget not found`, task: modifyTask(func(t *api.Task) { t.Spec = api.TaskSpec{ Runtime: &api.TaskSpec_Container{ From 5cfdd802269822c795774ec8342f0e95dd0fa129 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 19 Aug 2019 23:51:59 +0200 Subject: [PATCH 5/5] YOLO see if this works ``` panic: Log in goroutine after TestWorkerUpdate has completed goroutine 1175 [running]: testing.(*common).logDepth(0xc00019a100, 0xc0000396a0, 0x1d, 0x3) /usr/local/go/src/testing/testing.go:634 +0x51a testing.(*common).log(...) /usr/local/go/src/testing/testing.go:614 testing.(*common).Log(0xc00019a100, 0xc00006fb00, 0x1, 0x1) /usr/local/go/src/testing/testing.go:642 +0x79 github.com/docker/swarmkit/agent.(*mockTaskController).Remove(0xc00020a780, 0x13b6f40, 0xc0000b4010, 0x13b6f40, 0xc0000b4010) /home/circleci/.go_workspace/src/github.com/docker/swarmkit/agent/worker_test.go:604 +0x8e github.com/docker/swarmkit/agent.reconcileTaskState.func1(0xc0004dac60) /home/circleci/.go_workspace/src/github.com/docker/swarmkit/agent/worker.go:270 +0x137 created by github.com/docker/swarmkit/agent.reconcileTaskState /home/circleci/.go_workspace/src/github.com/docker/swarmkit/agent/worker.go:313 +0x1a6f FAIL github.com/docker/swarmkit/agent 4.244s make: *** [coverage] Error 1 Exited with code 2 ``` Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 42085d2f8e43a3ed90ed289d3f3ed3de57837100) Signed-off-by: Sebastiaan van Stijn --- agent/worker.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/agent/worker.go b/agent/worker.go index efe538afa7..212aa1e12f 100644 --- a/agent/worker.go +++ b/agent/worker.go @@ -257,13 +257,11 @@ func reconcileTaskState(ctx context.Context, w *worker, assignments []*api.Assig } closeManager := func(tm *taskManager) { - go func(tm *taskManager) { - defer w.closers.Done() - // when a task is no longer assigned, we shutdown the task manager - if err := tm.Close(); err != nil { - log.G(ctx).WithError(err).Error("error closing task manager") - } - }(tm) + defer w.closers.Done() + // when a task is no longer assigned, we shutdown the task manager + if err := tm.Close(); err != nil { + log.G(ctx).WithError(err).Error("error closing task manager") + } // make an attempt at removing. this is best effort. any errors will be // retried by the reaper later.