mirror of
https://github.com/prometheus/prometheus
synced 2024-12-25 16:02:28 +00: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()
|
||||
|
||||
for set.Next() {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return apiFuncResult{nil, returnAPIError(err), warnings, closer}
|
||||
}
|
||||
metrics = append(metrics, set.At().Labels())
|
||||
|
||||
if len(metrics) >= limit {
|
||||
|
@ -3568,6 +3568,9 @@ func TestReturnAPIError(t *testing.T) {
|
||||
}, {
|
||||
err: errors.New("exec error"),
|
||||
expected: errorExec,
|
||||
}, {
|
||||
err: context.Canceled,
|
||||
expected: errorCanceled,
|
||||
},
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user