Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing: fix race condition reading data from containers #711

Merged
merged 1 commit into from
Feb 1, 2018

Conversation

cezarsa
Copy link
Collaborator

@cezarsa cezarsa commented Jan 31, 2018

Example of a race caught by the race detector:

==================
WARNING: DATA RACE
Write at 0x00c4201dea68 by goroutine 374:
  github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing.(*DockerServer).stopContainer()
      /home/travis/gopath/src/github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing/server.go:726 +0x15a
  github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing.(*DockerServer).(github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing.stopContainer)-fm()
      /home/travis/gopath/src/github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing/server.go:169 +0x5f
  github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing.(*DockerServer).handlerWrapper.func1()
      /home/travis/gopath/src/github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing/server.go:379 +0x70a
  net/http.HandlerFunc.ServeHTTP()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/net/http/server.go:1918 +0x51
  github.com/tsuru/tsuru/vendor/github.com/gorilla/mux.(*Router).ServeHTTP()
      /home/travis/gopath/src/github.com/tsuru/tsuru/vendor/github.com/gorilla/mux/mux.go:133 +0x18a
  github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing.(*DockerServer).ServeHTTP()
      /home/travis/gopath/src/github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing/server.go:340 +0x271
  net/http.serverHandler.ServeHTTP()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/net/http/server.go:2619 +0xbc
  net/http.(*conn).serve()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/net/http/server.go:1801 +0x83b
Previous read at 0x00c4201dea68 by goroutine 357:
  reflect.Value.Bool()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/reflect/value.go:248 +0x52
  encoding/json.isEmptyValue()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/encoding/json/encode.go:309 +0xd4
  encoding/json.(*structEncoder).encode()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/encoding/json/encode.go:626 +0x31f
  encoding/json.(*structEncoder).(encoding/json.encode)-fm()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/encoding/json/encode.go:651 +0x7b
  encoding/json.(*structEncoder).encode()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/encoding/json/encode.go:637 +0x2e2
  encoding/json.(*structEncoder).(encoding/json.encode)-fm()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/encoding/json/encode.go:651 +0x7b
  encoding/json.(*ptrEncoder).encode()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/encoding/json/encode.go:778 +0x12a
  encoding/json.(*ptrEncoder).(encoding/json.encode)-fm()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/encoding/json/encode.go:783 +0x7b
  encoding/json.(*encodeState).reflectValue()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/encoding/json/encode.go:323 +0x93
  encoding/json.(*encodeState).marshal()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/encoding/json/encode.go:296 +0xbc
  encoding/json.(*Encoder).Encode()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/encoding/json/stream.go:193 +0xda
  github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing.(*DockerServer).inspectContainer()
      /home/travis/gopath/src/github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing/server.go:569 +0x289
  github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing.(*DockerServer).(github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing.inspectContainer)-fm()
      /home/travis/gopath/src/github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing/server.go:165 +0x5f
  github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing.(*DockerServer).handlerWrapper.func1()
      /home/travis/gopath/src/github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing/server.go:379 +0x70a
  net/http.HandlerFunc.ServeHTTP()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/net/http/server.go:1918 +0x51
  github.com/tsuru/tsuru/vendor/github.com/gorilla/mux.(*Router).ServeHTTP()
      /home/travis/gopath/src/github.com/tsuru/tsuru/vendor/github.com/gorilla/mux/mux.go:133 +0x18a
  github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing.(*DockerServer).ServeHTTP()
      /home/travis/gopath/src/github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing/server.go:340 +0x271
  net/http.serverHandler.ServeHTTP()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/net/http/server.go:2619 +0xbc
  net/http.(*conn).serve()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/net/http/server.go:1801 +0x83b
Goroutine 374 (running) created at:
  net/http.(*Server).Serve()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/net/http/server.go:2720 +0x37c
  net/http.Serve()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/net/http/server.go:2323 +0xe2
Goroutine 357 (finished) created at:
  net/http.(*Server).Serve()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/net/http/server.go:2720 +0x37c
  net/http.Serve()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/net/http/server.go:2323 +0xe2
==================

Example of a race caught by the race detector:

```
==================
WARNING: DATA RACE
Write at 0x00c4201dea68 by goroutine 374:
  github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing.(*DockerServer).stopContainer()
      /home/travis/gopath/src/github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing/server.go:726 +0x15a
  github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing.(*DockerServer).(github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing.stopContainer)-fm()
      /home/travis/gopath/src/github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing/server.go:169 +0x5f
  github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing.(*DockerServer).handlerWrapper.func1()
      /home/travis/gopath/src/github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing/server.go:379 +0x70a
  net/http.HandlerFunc.ServeHTTP()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/net/http/server.go:1918 +0x51
  github.com/tsuru/tsuru/vendor/github.com/gorilla/mux.(*Router).ServeHTTP()
      /home/travis/gopath/src/github.com/tsuru/tsuru/vendor/github.com/gorilla/mux/mux.go:133 +0x18a
  github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing.(*DockerServer).ServeHTTP()
      /home/travis/gopath/src/github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing/server.go:340 +0x271
  net/http.serverHandler.ServeHTTP()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/net/http/server.go:2619 +0xbc
  net/http.(*conn).serve()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/net/http/server.go:1801 +0x83b
Previous read at 0x00c4201dea68 by goroutine 357:
  reflect.Value.Bool()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/reflect/value.go:248 +0x52
  encoding/json.isEmptyValue()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/encoding/json/encode.go:309 +0xd4
  encoding/json.(*structEncoder).encode()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/encoding/json/encode.go:626 +0x31f
  encoding/json.(*structEncoder).(encoding/json.encode)-fm()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/encoding/json/encode.go:651 +0x7b
  encoding/json.(*structEncoder).encode()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/encoding/json/encode.go:637 +0x2e2
  encoding/json.(*structEncoder).(encoding/json.encode)-fm()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/encoding/json/encode.go:651 +0x7b
  encoding/json.(*ptrEncoder).encode()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/encoding/json/encode.go:778 +0x12a
  encoding/json.(*ptrEncoder).(encoding/json.encode)-fm()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/encoding/json/encode.go:783 +0x7b
  encoding/json.(*encodeState).reflectValue()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/encoding/json/encode.go:323 +0x93
  encoding/json.(*encodeState).marshal()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/encoding/json/encode.go:296 +0xbc
  encoding/json.(*Encoder).Encode()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/encoding/json/stream.go:193 +0xda
  github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing.(*DockerServer).inspectContainer()
      /home/travis/gopath/src/github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing/server.go:569 +0x289
  github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing.(*DockerServer).(github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing.inspectContainer)-fm()
      /home/travis/gopath/src/github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing/server.go:165 +0x5f
  github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing.(*DockerServer).handlerWrapper.func1()
      /home/travis/gopath/src/github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing/server.go:379 +0x70a
  net/http.HandlerFunc.ServeHTTP()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/net/http/server.go:1918 +0x51
  github.com/tsuru/tsuru/vendor/github.com/gorilla/mux.(*Router).ServeHTTP()
      /home/travis/gopath/src/github.com/tsuru/tsuru/vendor/github.com/gorilla/mux/mux.go:133 +0x18a
  github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing.(*DockerServer).ServeHTTP()
      /home/travis/gopath/src/github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing/server.go:340 +0x271
  net/http.serverHandler.ServeHTTP()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/net/http/server.go:2619 +0xbc
  net/http.(*conn).serve()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/net/http/server.go:1801 +0x83b
Goroutine 374 (running) created at:
  net/http.(*Server).Serve()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/net/http/server.go:2720 +0x37c
  net/http.Serve()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/net/http/server.go:2323 +0xe2
Goroutine 357 (finished) created at:
  net/http.(*Server).Serve()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/net/http/server.go:2720 +0x37c
  net/http.Serve()
      /home/travis/.gimme/versions/go1.9.2.linux.amd64/src/net/http/server.go:2323 +0xe2
==================
```
@fsouza fsouza merged commit ddfd07a into fsouza:master Feb 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants