From 60648672518b642ea3b4dcab431ca521b3e6597b Mon Sep 17 00:00:00 2001 From: Chris Baker <1675087+cgbaker@users.noreply.github.com> Date: Tue, 6 Apr 2021 18:04:56 +0000 Subject: [PATCH] sdk: header map copy to avoid race condition in #10301 --- CHANGELOG.md | 1 + api/api.go | 4 ++-- vendor/github.com/hashicorp/nomad/api/api.go | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b81974292..21ecee3dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 race condition around headers in API client [[GH-10302](https://github.com/hashicorp/nomad/issues/10302)] * api: Added missing devices block to AllocatedTaskResources [[GH-10064](https://github.com/hashicorp/nomad/pull/10064)] * cli: Fixed a bug where non-int proxy port would panic CLI [[GH-10072](https://github.com/hashicorp/nomad/issues/10072)] * cli: Fixed a bug where `nomad operator debug` incorrectly parsed https Consul API URLs. [[GH-10082](https://github.com/hashicorp/nomad/pull/10082)] diff --git a/api/api.go b/api/api.go index d2deff274..7ce7d9a13 100644 --- a/api/api.go +++ b/api/api.go @@ -685,8 +685,8 @@ func (c *Client) newRequest(method, path string) (*request, error) { } } - if c.config.Headers != nil { - r.header = c.config.Headers + for key, values := range c.config.Headers { + r.header[key] = values } return r, nil diff --git a/vendor/github.com/hashicorp/nomad/api/api.go b/vendor/github.com/hashicorp/nomad/api/api.go index d2deff274..7ce7d9a13 100644 --- a/vendor/github.com/hashicorp/nomad/api/api.go +++ b/vendor/github.com/hashicorp/nomad/api/api.go @@ -685,8 +685,8 @@ func (c *Client) newRequest(method, path string) (*request, error) { } } - if c.config.Headers != nil { - r.header = c.config.Headers + for key, values := range c.config.Headers { + r.header[key] = values } return r, nil