-
Notifications
You must be signed in to change notification settings - Fork 2k
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
fix potential race condition in API client #10302
Conversation
6fef42d
to
88eb81b
Compare
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.
LGTM. I suspect the significant violation here is that we are mutating the input header object, resulting into a request contaminating subsequent requests even without concurrency. The concurrency race is a consequence of that.
Correct. It's not necessarily even us... the downstream code in It is possible that an auth token or another field from a request-specific |
enable -race detector for testing api
1bee19e
to
4e25e8e
Compare
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.
Couple of tweaks - but feel free to merge as you see fit.
.circleci/config.yml
Outdated
@@ -293,11 +293,15 @@ jobs: | |||
goarch: | |||
type: string | |||
default: "amd64" | |||
enable_race_testing: | |||
type: string |
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.
Would this be better as a boolean?
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.
for the circleci bit, probably. however, downstream usage would require that it be converted to an empty string when false
, because of the way that conditionals work in GNU make:
https://github.com/hashicorp/nomad/pull/10302/files#diff-78a8a19706dbd2a4425dd72bdab0502ed7a2cef16365ab7030a5a0588927bf47R304
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.
okay, i've changed my mind. will do that, at least for the purpose of documentation.
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.
@notnoop , when you have a chance, i'd appreciate your feedback on this approach.
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.
environment: | ||
GOTEST_PKGS_EXCLUDE: "<< parameters.exclude_packages >>" | ||
GOTEST_PKGS: "<< parameters.test_packages >>" | ||
GOTEST_MOD: "<< parameters.test_module >>" | ||
GOTESTARCH: "<< parameters.goarch >>" | ||
ENABLE_RACE: "<<# parameters.enable_race_testing >>TRUE<</ parameters.enable_race_testing >>" |
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.
TIL about circleci conditionals!
@@ -17,6 +17,7 @@ IMPROVEMENTS: | |||
|
|||
BUG FIXES: | |||
* agent: Only allow querying Prometheus formatted metrics if Prometheus is enabled within the config [[GH-10140](https://github.com/hashicorp/nomad/pull/10140)] | |||
* api: Fixed a panic that may occur on concurrent access to an SDK client [[GH-10302](https://github.com/hashicorp/nomad/issues/10302)] |
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.
💯 This is even better than I was proposing about - thanks!
…ition fix potential race condition in API client
I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions. |
Resolves #10301
/api
tests to run with-race
.Commit 4e25e8e shows a documenting test, which fails under
-race
:https://app.circleci.com/pipelines/github/hashicorp/nomad/15527/workflows/d2032205-895a-4d7b-8ec6-41301a1614cb/jobs/147802
New test passes after 6064867