-
Notifications
You must be signed in to change notification settings - Fork 366
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
馃悰 cache: fix a datarace #2226
馃悰 cache: fix a datarace #2226
Conversation
if err := s.apiextensions.GenericAPIServer.AddPostStartHook("bootstrap-cache-server", func(hookContext genericapiserver.PostStartHookContext) error { | ||
logger = logger.WithValues("postStartHook", "bootstrap-cache-server") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or make it just logger :=
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the context of the hook lacks potentially some keys.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pushed, ptal.
the logger object needs to be created when a webhook is created otherwise it can be accessed from multiple goroutines. ================== WARNING: DATA RACE Read at 0x00c000b59a28 by goroutine 212: runtime.racereadrange() <autogenerated>:1 +0x1b k8s.io/apiserver/pkg/server.runPostStartHook.func1() /go/pkg/mod/github.com/kcp-dev/kubernetes/staging/src/k8s.io/apiserver@v0.0.0-20221005071841-6cfb7d485cbf/pkg/server/hooks.go:198 +0xa1 k8s.io/apiserver/pkg/server.runPostStartHook() /go/pkg/mod/github.com/kcp-dev/kubernetes/staging/src/k8s.io/apiserver@v0.0.0-20221005071841-6cfb7d485cbf/pkg/server/hooks.go:199 +0xda k8s.io/apiserver/pkg/server.(*GenericAPIServer).RunPostStartHooks.func2() /go/pkg/mod/github.com/kcp-dev/kubernetes/staging/src/k8s.io/apiserver@v0.0.0-20221005071841-6cfb7d485cbf/pkg/server/hooks.go:165 +0xb4 Previous write at 0x00c000b59a28 by goroutine 210: github.com/kcp-dev/kcp/pkg/cache/server.(*Server).PrepareRun.func1() /go/src/github.com/kcp-dev/kcp/pkg/cache/server/server.go:57 +0x196 k8s.io/apiserver/pkg/server.runPostStartHook.func1() /go/pkg/mod/github.com/kcp-dev/kubernetes/staging/src/k8s.io/apiserver@v0.0.0-20221005071841-6cfb7d485cbf/pkg/server/hooks.go:198 +0xa1 k8s.io/apiserver/pkg/server.runPostStartHook() /go/pkg/mod/github.com/kcp-dev/kubernetes/staging/src/k8s.io/apiserver@v0.0.0-20221005071841-6cfb7d485cbf/pkg/server/hooks.go:199 +0xda k8s.io/apiserver/pkg/server.(*GenericAPIServer).RunPostStartHooks.func2() /go/pkg/mod/github.com/kcp-dev/kubernetes/staging/src/k8s.io/apiserver@v0.0.0-20221005071841-6cfb7d485cbf/pkg/server/hooks.go:165 +0xb4 Goroutine 212 (running) created at: k8s.io/apiserver/pkg/server.(*GenericAPIServer).RunPostStartHooks() /go/pkg/mod/github.com/kcp-dev/kubernetes/staging/src/k8s.io/apiserver@v0.0.0-20221005071841-6cfb7d485cbf/pkg/server/hooks.go:165 +0x167 k8s.io/apiserver/pkg/server.preparedGenericAPIServer.NonBlockingRun() /go/pkg/mod/github.com/kcp-dev/kubernetes/staging/src/k8s.io/apiserver@v0.0.0-20221005071841-6cfb7d485cbf/pkg/server/genericapiserver.go:572 +0x28a k8s.io/apiserver/pkg/server.preparedGenericAPIServer.Run() /go/pkg/mod/github.com/kcp-dev/kubernetes/staging/src/k8s.io/apiserver@v0.0.0-20221005071841-6cfb7d485cbf/pkg/server/genericapiserver.go:497 +0x7c8 github.com/kcp-dev/kcp/pkg/cache/server.preparedServer.Run() /go/src/github.com/kcp-dev/kcp/pkg/cache/server/server.go:84 +0x93 github.com/kcp-dev/kcp/test/e2e/reconciler/cache.TestAllScenariosAgainstStandaloneCacheServer.func1() /go/src/github.com/kcp-dev/kcp/test/e2e/reconciler/cache/replication_test.go:230 +0x67 Goroutine 210 (running) created at: k8s.io/apiserver/pkg/server.(*GenericAPIServer).RunPostStartHooks() /go/pkg/mod/github.com/kcp-dev/kubernetes/staging/src/k8s.io/apiserver@v0.0.0-20221005071841-6cfb7d485cbf/pkg/server/hooks.go:165 +0x167 k8s.io/apiserver/pkg/server.preparedGenericAPIServer.NonBlockingRun() /go/pkg/mod/github.com/kcp-dev/kubernetes/staging/src/k8s.io/apiserver@v0.0.0-20221005071841-6cfb7d485cbf/pkg/server/genericapiserver.go:572 +0x28a k8s.io/apiserver/pkg/server.preparedGenericAPIServer.Run() /go/pkg/mod/github.com/kcp-dev/kubernetes/staging/src/k8s.io/apiserver@v0.0.0-20221005071841-6cfb7d485cbf/pkg/server/genericapiserver.go:497 +0x7c8 github.com/kcp-dev/kcp/pkg/cache/server.preparedServer.Run() /go/src/github.com/kcp-dev/kcp/pkg/cache/server/server.go:84 +0x93 github.com/kcp-dev/kcp/test/e2e/reconciler/cache.TestAllScenariosAgainstStandaloneCacheServer.func1() /go/src/github.com/kcp-dev/kcp/test/e2e/reconciler/cache/replication_test.go:230 +0x67 ==================
8447b7d
to
68bf8dc
Compare
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: sttts The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest |
Summary
the logger object needs to be created when a webhook is created otherwise it can be accessed from multiple goroutines.
Related issue(s)
part of #342