Skip to content

Commit c82e409

Browse files
authored
Merge pull request #2769 from anshulpundir/backport
[bump_v18.09] Fix nil pointer dereference in node allocation, linter fixes
2 parents 3044c57 + 01cc213 commit c82e409

149 files changed

Lines changed: 450 additions & 445 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.circleci/config.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
ARCH: amd64
1414
GOVERSION: 1.10.3
1515
# Needed to install protoc
16-
PROTOC: https://github.com/google/protobuf/releases/download/v3.5.0/protoc-3.5.0-linux-x86_64.zip
16+
PROTOC_VERSION: 3.6.1
1717

1818
# Note(cyli): We create a tmpfs mount to be used for temporary files created by tests
1919
# to mitigate the excessive I/O latencies that sometimes cause the tests to fail.
@@ -61,12 +61,11 @@ jobs:
6161
- run:
6262
name: Install protoc
6363
command: |
64-
curl -fsSL -o "$HOME/$(basename $PROTOC)" "$PROTOC"
65-
unzip -o "$HOME/$(basename $PROTOC)" -d "$HOME"
66-
sudo cp -R "$HOME/include/google" /usr/local/include
67-
sudo chmod 777 -R /usr/local/include/google
68-
sudo cp -R "$HOME/bin/protoc" /usr/local/bin
69-
sudo chmod 777 /usr/local/bin/protoc
64+
curl --silent --show-error --location --output protoc.zip \
65+
https://github.com/google/protobuf/releases/download/v$PROTOC_VERSION/protoc-$PROTOC_VERSION-linux-x86_64.zip \
66+
&& sudo unzip -d /usr/local protoc.zip include/\* bin\/* \
67+
&& sudo chmod -R a+r /usr/local/include/google/protobuf/
68+
rm -f protoc.zip
7069
7170
- run:
7271
name: Install test/lint dependencies

.gometalinter.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"Vendor": true,
3+
"Exclude": [
4+
".*\\.pb\\.go"
5+
],
6+
"Enable": [
7+
"vet",
8+
"misspell",
9+
"gofmt",
10+
"goimports",
11+
"golint",
12+
"gosimple",
13+
"ineffassign",
14+
"deadcode",
15+
"unconvert"
16+
],
17+
"Deadline": "2m"
18+
}

Dockerfile

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,13 @@ FROM golang:1.10.3-stretch
33

44
RUN apt-get update && apt-get install -y make git unzip
55

6-
# should stay consistent with the version we use in Circle builds
7-
ARG PROTOC_VERSION=3.5.0
8-
# make a directory to do these operations in
9-
RUN export PROTOC_TMP_DIR=protoc && mkdir -p $PROTOC_TMP_DIR && cd $PROTOC_TMP_DIR \
10-
# download the pre-built protoc binary
11-
&& curl --silent --show-error --location --output protoc.zip \
12-
https://github.com/google/protobuf/releases/download/v$PROTOC_VERSION/protoc-$PROTOC_VERSION-linux-x86_64.zip \
13-
# move the binary to /bin. move the well-known types ot /usr/local/include
14-
&& unzip protoc.zip && mv bin/protoc /bin/protoc && mv include/* /usr/local/include \
15-
# remove all of the installation files
16-
&& cd .. && rm -rf $PROTOC_TMP_DIR
6+
# should stay consistent with the version in .circleci/config.yml
7+
ARG PROTOC_VERSION=3.6.1
8+
# download and install protoc binary and .proto files
9+
RUN curl --silent --show-error --location --output protoc.zip \
10+
https://github.com/google/protobuf/releases/download/v$PROTOC_VERSION/protoc-$PROTOC_VERSION-linux-x86_64.zip \
11+
&& unzip -d /usr/local protoc.zip include/\* bin/\* \
12+
&& rm -f protoc.zip
1713

1814
WORKDIR /go/src/github.com/docker/swarmkit/
1915

agent/agent.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package agent
22

33
import (
44
"bytes"
5+
"context"
56
"math/rand"
67
"reflect"
78
"sync"
@@ -11,7 +12,6 @@ import (
1112
"github.com/docker/swarmkit/api"
1213
"github.com/docker/swarmkit/log"
1314
"github.com/pkg/errors"
14-
"golang.org/x/net/context"
1515
)
1616

1717
const (

agent/agent_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package agent
22

33
import (
4+
"context"
45
"crypto/tls"
56
"errors"
67
"fmt"
@@ -25,7 +26,6 @@ import (
2526
"github.com/docker/swarmkit/xnet"
2627
"github.com/stretchr/testify/assert"
2728
"github.com/stretchr/testify/require"
28-
"golang.org/x/net/context"
2929
)
3030

3131
var localDispatcher = false
@@ -90,7 +90,8 @@ func TestAgentStartStop(t *testing.T) {
9090
require.NoError(t, err)
9191
assert.NotNil(t, agent)
9292

93-
ctx, _ := context.WithTimeout(tc.Context, 5000*time.Millisecond)
93+
ctx, cancel := context.WithTimeout(tc.Context, 5000*time.Millisecond)
94+
defer cancel()
9495

9596
assert.Equal(t, errAgentNotStarted, agent.Stop(ctx))
9697
assert.NoError(t, agent.Start(ctx))

agent/errors.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,5 @@ var (
1313
errAgentStarted = errors.New("agent: already started")
1414
errAgentNotStarted = errors.New("agent: not started")
1515

16-
errTaskNoController = errors.New("agent: no task controller")
17-
errTaskNotAssigned = errors.New("agent: task not assigned")
18-
errTaskStatusUpdateNoChange = errors.New("agent: no change in task status")
19-
errTaskUnknown = errors.New("agent: task unknown")
20-
21-
errTaskInvalid = errors.New("task: invalid")
16+
errTaskUnknown = errors.New("agent: task unknown")
2217
)

agent/exec/controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package exec
22

33
import (
4+
"context"
45
"fmt"
56
"time"
67

@@ -10,7 +11,6 @@ import (
1011
"github.com/docker/swarmkit/protobuf/ptypes"
1112
"github.com/pkg/errors"
1213
"github.com/sirupsen/logrus"
13-
"golang.org/x/net/context"
1414
)
1515

1616
// Controller controls execution of a task.

agent/exec/controller_stub.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package exec
22

33
import (
4-
"github.com/docker/swarmkit/api"
5-
"golang.org/x/net/context"
4+
"context"
65
"runtime"
76
"strings"
7+
8+
"github.com/docker/swarmkit/api"
89
)
910

1011
// StubController implements the Controller interface,

agent/exec/controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package exec
22

33
import (
4+
"context"
45
"errors"
56
"fmt"
67
"runtime"
@@ -10,7 +11,6 @@ import (
1011
"github.com/docker/swarmkit/log"
1112
gogotypes "github.com/gogo/protobuf/types"
1213
"github.com/stretchr/testify/assert"
13-
"golang.org/x/net/context"
1414
)
1515

1616
func TestResolve(t *testing.T) {

agent/exec/dockerapi/adapter.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package dockerapi
22

33
import (
4+
"context"
45
"encoding/json"
56
"fmt"
67
"io"
@@ -16,7 +17,6 @@ import (
1617
gogotypes "github.com/gogo/protobuf/types"
1718
"github.com/pkg/errors"
1819
"github.com/sirupsen/logrus"
19-
"golang.org/x/net/context"
2020
"golang.org/x/time/rate"
2121
)
2222

@@ -144,15 +144,13 @@ func (c *containerAdapter) removeNetworks(ctx context.Context) error {
144144
}
145145

146146
func (c *containerAdapter) create(ctx context.Context) error {
147-
if _, err := c.client.ContainerCreate(ctx,
147+
_, err := c.client.ContainerCreate(ctx,
148148
c.container.config(),
149149
c.container.hostConfig(),
150150
c.container.networkingConfig(),
151-
c.container.name()); err != nil {
152-
return err
153-
}
151+
c.container.name())
154152

155-
return nil
153+
return err
156154
}
157155

158156
func (c *containerAdapter) start(ctx context.Context) error {

0 commit comments

Comments
 (0)