pkg: fix data race around HasASessionRequested
TestCreateSSHShell fails when running "go test --race", because of concurrent accesses from multiple goroutines. ``` WARNING: DATA RACE Read at 0x00c42025b730 by goroutine 42: k8s.io/minikube/pkg/minikube/cluster.TestCreateSSHShell() k8s.io/minikube/pkg/minikube/cluster/cluster_test.go:523 +0x543 testing.tRunner() /usr/local/golang/src/testing/testing.go:657 +0x107 Previous write at 0x00c42025b730 by goroutine 49: k8s.io/minikube/pkg/minikube/tests.(*SSHServer).Start.func1.1() k8s.io/minikube/pkg/minikube/tests/ssh_mock.go:95 +0x743 ``` To fix that, convert HadASessionRequested to an atomic variable. Callers should run helper functions, SetSessionRequested() and IsSessionRequested() instead of direct access to the variable.
Showing
想要评论请 注册 或 登录