-
Notifications
You must be signed in to change notification settings - Fork 3.4k
proxy/proxyports: fix flake and data race in TestPortAllocator #38062
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Access to (*ProxyPorts).nRedirects needs to happen with (*ProxyPorts).mutex locked to avoid the following data race: WARNING: DATA RACE Read at 0x00c000365f38 by goroutine 24: github.com/cilium/cilium/pkg/proxy/proxyports.(*ProxyPorts).releaseProxyPort.func1() /home/tklauser/go/src/github.com/cilium/cilium/pkg/proxy/proxyports/proxyports.go:402 +0x224 Previous write at 0x00c000365f38 by goroutine 22: github.com/cilium/cilium/pkg/proxy/proxyports.(*ProxyPorts).releaseProxyPort() /home/tklauser/go/src/github.com/cilium/cilium/pkg/proxy/proxyports/proxyports.go:388 +0xf6 github.com/cilium/cilium/pkg/proxy/proxyports.TestPortAllocator() /home/tklauser/go/src/github.com/cilium/cilium/pkg/proxy/proxyports/proxyports_test.go:147 +0x13e5 testing.tRunner() /usr/local/go/src/testing/testing.go:1792 +0x225 testing.(*T).Run.gowrap1() /usr/local/go/src/testing/testing.go:1851 +0x44 Goroutine 24 (running) created at: github.com/cilium/cilium/pkg/proxy/proxyports.(*ProxyPorts).releaseProxyPort() /home/tklauser/go/src/github.com/cilium/cilium/pkg/proxy/proxyports/proxyports.go:396 +0x30f github.com/cilium/cilium/pkg/proxy/proxyports.TestPortAllocator() /home/tklauser/go/src/github.com/cilium/cilium/pkg/proxy/proxyports/proxyports_test.go:75 +0x77a testing.tRunner() /usr/local/go/src/testing/testing.go:1792 +0x225 testing.(*T).Run.gowrap1() /usr/local/go/src/testing/testing.go:1851 +0x44 Goroutine 22 (running) created at: testing.(*T).Run() /usr/local/go/src/testing/testing.go:1851 +0x8f2 testing.runTests.func1() /usr/local/go/src/testing/testing.go:2279 +0x85 testing.tRunner() /usr/local/go/src/testing/testing.go:1792 +0x225 testing.runTests() /usr/local/go/src/testing/testing.go:2277 +0x96c testing.(*M).Run() /usr/local/go/src/testing/testing.go:2142 +0xeea main.main() _testmain.go:47 +0x164 This can easily be reproduced by running: go test -race -c ./pkg/proxy/proxyports && stress ./proxyports.test The godoc comment for (*ProxyPorts).releaseProxyPort also specifies that it needs to be called with (*ProxyPorts).mutex held, so let's lock it when using it in TestPortAllocator. Signed-off-by: Tobias Klauser <tobias@cilium.io>
/test |
sayboras
approved these changes
Mar 7, 2025
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.
nice finding 👍
discussed with @mhofstetter that this also affects the v1.17 branch |
3 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area/CI
Continuous Integration testing issue or flake
area/CI-improvement
Topic or proposal to improve the Continuous Integration workflow
backport-done/1.17
The backport for Cilium 1.17.x for this PR is done.
ready-to-merge
This PR has passed all tests and received consensus from code owners to merge.
release-note/ci
This PR makes changes to the CI.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Access to
(*ProxyPorts).nRedirects
needs to happen with(*ProxyPorts).mutex
locked to avoid the following data race:This can easily be reproduced by running:
The godoc comment for
(*ProxyPorts).releaseProxyPort
also specifies that it needs to be called with(*ProxyPorts).mutex
held, so let's lock it when using it inTestPortAllocator
.Fixes #36375