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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Race condition in SDK client #10301

Closed
cgbaker opened this issue Apr 5, 2021 · 1 comment · Fixed by #10302
Closed

Race condition in SDK client #10301

cgbaker opened this issue Apr 5, 2021 · 1 comment · Fixed by #10302
Assignees
Labels
theme/api HTTP API and SDK issues type/bug
Milestone

Comments

@cgbaker
Copy link
Contributor

cgbaker commented Apr 5, 2021

Nomad version

v1.0.4 (and much before)

Issue

When headers are present on the Nomad client config, the header map from the config is assigned to the request header map in newRequest:
https://github.com/hashicorp/nomad/blob/v1.0.4/api/api.go#L680-L682
This means that downstream usage of this header map (esp. mutation) can result in concurrent access to the map from the client config. We ran into this problem in the Nomad terraform provider:
https://travis-ci.org/github/hashicorp/terraform-provider-nomad/builds/765624353

The assignment linked above needs to be a copy, in the spirit of the initialization in doRequest:
https://github.com/hashicorp/nomad/blob/v1.0.4/api/api.go#L657

Reproduction steps

Documenting test in #10302

@cgbaker cgbaker self-assigned this Apr 5, 2021
@cgbaker cgbaker added this to the 1.1.0 milestone Apr 5, 2021
@cgbaker cgbaker added the theme/api HTTP API and SDK issues label Apr 5, 2021
cgbaker added a commit that referenced this issue Apr 5, 2021
cgbaker added a commit that referenced this issue Apr 6, 2021
enable -race detector for testing api
@github-actions
Copy link

I'm going to lock this issue because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
theme/api HTTP API and SDK issues type/bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant