mirror of
https://github.com/prometheus/prometheus.git
synced 2025-02-21 03:16:00 -08:00
add context cancellation check at get series result iteration (#13766)
* add context cancellation check at get series iteration * add warnings and closer on error * add test --------- Signed-off-by: Erlan Zholdubai uulu <erlanz@amazon.com>
This commit is contained in:
parent
16164226e5
commit
742196b6c4
|
@ -882,6 +882,9 @@ func (api *API) series(r *http.Request) (result apiFuncResult) {
|
||||||
warnings := set.Warnings()
|
warnings := set.Warnings()
|
||||||
|
|
||||||
for set.Next() {
|
for set.Next() {
|
||||||
|
if err := ctx.Err(); err != nil {
|
||||||
|
return apiFuncResult{nil, returnAPIError(err), warnings, closer}
|
||||||
|
}
|
||||||
metrics = append(metrics, set.At().Labels())
|
metrics = append(metrics, set.At().Labels())
|
||||||
|
|
||||||
if len(metrics) >= limit {
|
if len(metrics) >= limit {
|
||||||
|
|
|
@ -3568,6 +3568,9 @@ func TestReturnAPIError(t *testing.T) {
|
||||||
}, {
|
}, {
|
||||||
err: errors.New("exec error"),
|
err: errors.New("exec error"),
|
||||||
expected: errorExec,
|
expected: errorExec,
|
||||||
|
}, {
|
||||||
|
err: context.Canceled,
|
||||||
|
expected: errorCanceled,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue