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 data race when reading container state in some handlers #701

Merged
merged 1 commit into from
Dec 12, 2017

Conversation

cezarsa
Copy link
Collaborator

@cezarsa cezarsa commented Dec 12, 2017

Example of data race found:

==================
WARNING: DATA RACE
Write at 0x00c420df4468 by goroutine 559:
  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:724 +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 0x00c420df4468 by goroutine 165:
  github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing.(*DockerServer).attachContainer()
      /home/travis/gopath/src/github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing/server.go:790 +0x356
  github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing.(*DockerServer).(github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing.attachContainer)-fm()
      /home/travis/gopath/src/github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing/server.go:174 +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 559 (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 165 (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
==================

Example of data race found:

```
==================
WARNING: DATA RACE
Write at 0x00c420df4468 by goroutine 559:
  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:724 +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 0x00c420df4468 by goroutine 165:
  github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing.(*DockerServer).attachContainer()
      /home/travis/gopath/src/github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing/server.go:790 +0x356
  github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing.(*DockerServer).(github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing.attachContainer)-fm()
      /home/travis/gopath/src/github.com/tsuru/tsuru/vendor/github.com/fsouza/go-dockerclient/testing/server.go:174 +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 559 (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 165 (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
==================
```
@fsouza fsouza merged commit 413e380 into fsouza:master Dec 12, 2017
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