mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-01-30 15:22:07 +00:00
lib/promscrape/discovery/consul: make sure that block response contains X-Consul-Index header
This commit is contained in:
parent
5009b25a03
commit
9cd8eb92f1
1 changed files with 19 additions and 16 deletions
|
@ -126,7 +126,11 @@ func getBlockingAPIResponse(client *discoveryutils.Client, path string, index in
|
|||
path += "&index=" + strconv.FormatInt(index, 10)
|
||||
path += "&wait=" + maxWaitTimeStr
|
||||
getMeta := func(resp *fasthttp.Response) {
|
||||
if ind := resp.Header.Peek("X-Consul-Index"); len(ind) > 0 {
|
||||
ind := resp.Header.Peek("X-Consul-Index")
|
||||
if len(ind) == 0 {
|
||||
logger.Errorf("cannot find X-Consul-Index header in response from %q", path)
|
||||
return
|
||||
}
|
||||
newIndex, err := strconv.ParseInt(string(ind), 10, 64)
|
||||
if err != nil {
|
||||
logger.Errorf("cannot parse X-Consul-Index header value in response from %q: %s", path, err)
|
||||
|
@ -143,7 +147,6 @@ func getBlockingAPIResponse(client *discoveryutils.Client, path string, index in
|
|||
}
|
||||
index = newIndex
|
||||
}
|
||||
}
|
||||
data, err := client.GetBlockingAPIResponse(path, getMeta)
|
||||
if err != nil {
|
||||
return nil, index, fmt.Errorf("cannot perform blocking Consul API request at %q: %w", path, err)
|
||||
|
|
Loading…
Reference in a new issue