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

Store: Don't error when no stores are matched #6082

Merged
merged 2 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re
- [#6050](https://github.com/thanos-io/thanos/pull/6050) Store: Re-try bucket store initial sync upon failure.
- [#6066](https://github.com/thanos-io/thanos/pull/6066) Tracing: fixed panic because of nil sampler
- [#6067](https://github.com/thanos-io/thanos/pull/6067) Receive: fixed panic when querying uninitialized TSDBs.
- [#6082](https://github.com/thanos-io/thanos/pull/6082) Store: Don't error when no stores are matched.

### Changed

Expand Down
11 changes: 5 additions & 6 deletions pkg/store/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ type ctxKey int
// StoreMatcherKey is the context key for the store's allow list.
const StoreMatcherKey = ctxKey(0)

// ErrorNoStoresMatched is returned if the query does not match any data.
// This can happen with Query servers trees and external labels.
var ErrorNoStoresMatched = errors.New("No StoreAPIs matched for this query")

// Client holds meta information about a store.
type Client interface {
// StoreClient to access the store.
Expand Down Expand Up @@ -278,12 +282,7 @@ func (s *ProxyStore) Series(originalRequest *storepb.SeriesRequest, srv storepb.
}

if len(stores) == 0 {
err := errors.New("No StoreAPIs matched for this query")
level.Debug(reqLogger).Log("err", err, "stores", strings.Join(storeDebugMsgs, ";"))
if sendErr := srv.Send(storepb.NewWarnSeriesResponse(err)); sendErr != nil {
level.Error(reqLogger).Log("err", sendErr)
return status.Error(codes.Unknown, errors.Wrap(sendErr, "send series response").Error())
}
level.Debug(reqLogger).Log("err", ErrorNoStoresMatched, "stores", strings.Join(storeDebugMsgs, ";"))
return nil
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/store/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func TestProxyStore_Series(t *testing.T) {
MaxTime: 300,
Matchers: []storepb.LabelMatcher{{Name: "a", Value: "a", Type: storepb.LabelMatcher_EQ}},
},
expectedWarningsLen: 1, // No store matched for this query.
expectedWarningsLen: 0, // No store matched for this query.
},
{
title: "no storeAPI available for 301-302 time range",
Expand All @@ -153,7 +153,7 @@ func TestProxyStore_Series(t *testing.T) {
MaxTime: 400,
Matchers: []storepb.LabelMatcher{{Name: "a", Value: "a", Type: storepb.LabelMatcher_EQ}},
},
expectedWarningsLen: 1, // No store matched for this query.
expectedWarningsLen: 0, // No store matched for this query.
},
{
title: "storeAPI available for time range; no series for ext=2 external label matcher",
Expand All @@ -174,7 +174,7 @@ func TestProxyStore_Series(t *testing.T) {
MaxTime: 300,
Matchers: []storepb.LabelMatcher{{Name: "ext", Value: "2", Type: storepb.LabelMatcher_EQ}},
},
expectedWarningsLen: 1, // No store matched for this query.
expectedWarningsLen: 0, // No store matched for this query.
},
{
title: "storeAPI available for time range; available series for ext=1 external label matcher",
Expand Down Expand Up @@ -499,7 +499,7 @@ func TestProxyStore_Series(t *testing.T) {
Matchers: []storepb.LabelMatcher{{Name: "ext", Value: "1", Type: storepb.LabelMatcher_EQ}},
},
storeDebugMatchers: [][]*labels.Matcher{{labels.MustNewMatcher(labels.MatchEqual, "__address__", "foo")}},
expectedWarningsLen: 1, // No stores match.
expectedWarningsLen: 0, // No stores match.
},
{
title: "sharded series response",
Expand Down