Skip to content

Commit

Permalink
Make Query requests idempotent
Browse files Browse the repository at this point in the history
Address prometheus#1020.

Signed-off-by: Tomáš Dohnálek <dohnto@gmail.com>
  • Loading branch information
dohnto committed Apr 7, 2022
1 parent 29e8191 commit 24c0864
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions api/prometheus/v1/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1138,6 +1138,9 @@ func (h *apiClientImpl) DoGetFallback(ctx context.Context, u *url.URL, args url.
return nil, nil, nil, err
}
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
// Underlying `net.http` library automatically retries` idempotent requests when connectivity issues are hit.
// POST requests are not considered idempotent by default, so we need to explicitly mark them as such.
req.Header.Set("Idempotency-Key", "TODO")

resp, body, warnings, err := h.Do(ctx, req)
if resp != nil && (resp.StatusCode == http.StatusMethodNotAllowed || resp.StatusCode == http.StatusNotImplemented) {
Expand Down

0 comments on commit 24c0864

Please sign in to comment.