Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix query sharding with too many requests error #2447

Merged
merged 9 commits into from
Jul 19, 2022

Conversation

colega
Copy link
Contributor

@colega colega commented Jul 18, 2022

What this PR does

Handles the 429 status code when query sharding uses the prometheus codec.

Which issue(s) this PR fixes or relates to

Fixes #2169

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

Copy link
Contributor

@bboreham bboreham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Broadly seems fine; couple of thoughts below

@@ -438,3 +441,8 @@ func decorateWithParamName(err error, field string) error {
}
return apierror.Newf(apierror.TypeBadData, errTmpl, field, err)
}

func mustReadAll(r io.Reader) []byte {
body, _ := ioutil.ReadAll(r)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this use bodyBuffer(r), which DecodeResponse() calls on the non-error case ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's needed now, but it will definitely leave a more robust code, so replaced it here: a44e91b

Thanks.

require.NoError(t, distributor.WaitSumMetrics(e2e.Equals(512+1), "cortex_ring_tokens_total"))
require.NoError(t, querier.WaitSumMetrics(e2e.Equals(512), "cortex_ring_tokens_total"))

// Push a series for each user to Mimir.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"for each user" doesn't seem to match the code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too much copy-paste, fixed 0a80fdf

}

func TestQueryFrontendWithQueryShardingAndTooManyRequests(t *testing.T) {
runQueryFrontendWithQueryShardingAndTooManyRequestsTest := func(t *testing.T, cfg queryFrontendTestConfig) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making this a local func pushes indenting out; is it worth it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a strong opinion on this, so extracted: 85b9d95

@colega colega marked this pull request as ready for review July 18, 2022 15:05
Copy link
Contributor

@treid314 treid314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thank you for fixing this!

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
When using a local queue, the v1.Frontend responds with an
httpgrpc.Error when the queue is full. We need to convert that into a
429 http response instead of failing to roundtripping.

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
This will let us reuse the body if needed in the future.

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Queriers return errors that query-frontend cannot parse
3 participants