|
|
@ -231,6 +231,7 @@ func (c *Client) Store(ctx context.Context, req []byte, attempt int) error {
|
|
|
|
httpResp.Body.Close()
|
|
|
|
httpResp.Body.Close()
|
|
|
|
}()
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//nolint:usestdlibvars
|
|
|
|
if httpResp.StatusCode/100 != 2 {
|
|
|
|
if httpResp.StatusCode/100 != 2 {
|
|
|
|
scanner := bufio.NewScanner(io.LimitReader(httpResp.Body, maxErrMsgLen))
|
|
|
|
scanner := bufio.NewScanner(io.LimitReader(httpResp.Body, maxErrMsgLen))
|
|
|
|
line := ""
|
|
|
|
line := ""
|
|
|
@ -239,6 +240,7 @@ func (c *Client) Store(ctx context.Context, req []byte, attempt int) error {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
err = fmt.Errorf("server returned HTTP status %s: %s", httpResp.Status, line)
|
|
|
|
err = fmt.Errorf("server returned HTTP status %s: %s", httpResp.Status, line)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//nolint:usestdlibvars
|
|
|
|
if httpResp.StatusCode/100 == 5 ||
|
|
|
|
if httpResp.StatusCode/100 == 5 ||
|
|
|
|
(c.retryOnRateLimit && httpResp.StatusCode == http.StatusTooManyRequests) {
|
|
|
|
(c.retryOnRateLimit && httpResp.StatusCode == http.StatusTooManyRequests) {
|
|
|
|
return RecoverableError{err, retryAfterDuration(httpResp.Header.Get("Retry-After"))}
|
|
|
|
return RecoverableError{err, retryAfterDuration(httpResp.Header.Get("Retry-After"))}
|
|
|
@ -323,6 +325,7 @@ func (c *Client) Read(ctx context.Context, query *prompb.Query) (*prompb.QueryRe
|
|
|
|
return nil, fmt.Errorf("error reading response. HTTP status code: %s: %w", httpResp.Status, err)
|
|
|
|
return nil, fmt.Errorf("error reading response. HTTP status code: %s: %w", httpResp.Status, err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//nolint:usestdlibvars
|
|
|
|
if httpResp.StatusCode/100 != 2 {
|
|
|
|
if httpResp.StatusCode/100 != 2 {
|
|
|
|
return nil, fmt.Errorf("remote server %s returned HTTP status %s: %s", c.urlString, httpResp.Status, strings.TrimSpace(string(compressed)))
|
|
|
|
return nil, fmt.Errorf("remote server %s returned HTTP status %s: %s", c.urlString, httpResp.Status, strings.TrimSpace(string(compressed)))
|
|
|
|
}
|
|
|
|
}
|
|
|
|