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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 cache: fix a datarace #2226

Merged
merged 1 commit into from
Oct 20, 2022

Conversation

p0lyn0mial
Copy link
Contributor

Summary

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
==================

Related issue(s)

part of #342

if err := s.apiextensions.GenericAPIServer.AddPostStartHook("bootstrap-cache-server", func(hookContext genericapiserver.PostStartHookContext) error {
logger = logger.WithValues("postStartHook", "bootstrap-cache-server")
Copy link
Member

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 :=?

Copy link
Member

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.

Copy link
Contributor Author

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
==================
@sttts
Copy link
Member

sttts commented Oct 19, 2022

/lgtm
/approve

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Oct 19, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 19, 2022

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 19, 2022
@p0lyn0mial
Copy link
Contributor Author

/retest

@openshift-merge-robot openshift-merge-robot merged commit 75ee15b into kcp-dev:main Oct 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants