Skip to content

Commit

Permalink
store/proxy: set {Min,Max}Time accordingly to the nodes (#982)
Browse files Browse the repository at this point in the history
* store/proxy: set {Min,Max}Time accordingly to the nodes

It doesn't make sense to advertise that a Thanos Query node has data
since the beginning of the time and till the end of time if it only has
nodes which have specific time ranges of data.

Change it accordingly by checking each time range of each node and
setting it to the min/max values.

* store/proxy: add handling for edge case

In case there are no configured stores at Thanos Query we want to revert
to the old behaviour and inform the Info() callers that indeed we do
have all of the data.
  • Loading branch information
GiedriusS committed Mar 28, 2019
1 parent a5c3d2c commit 57a58a7
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions pkg/store/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,31 @@ func (s *ProxyStore) Info(ctx context.Context, r *storepb.InfoRequest) (*storepb
res := &storepb.InfoResponse{
Labels: make([]storepb.Label, 0, len(s.selectorLabels)),
StoreType: s.component.ToProto(),
MinTime: 0,
MaxTime: math.MaxInt64,
}

MinTime := int64(math.MaxInt64)
MaxTime := int64(0)

stores := s.stores()
for _, s := range stores {
mint, maxt := s.TimeRange()
if mint < MinTime {
MinTime = mint
}
if maxt > MaxTime {
MaxTime = maxt
}
}

// Edge case: we have all of the data if there are no stores.
if len(stores) == 0 {
MinTime = 0
MaxTime = math.MaxInt64
}

res.MaxTime = MaxTime
res.MinTime = MinTime

for _, l := range s.selectorLabels {
res.Labels = append(res.Labels, storepb.Label{
Name: l.Name,
Expand Down Expand Up @@ -393,7 +415,7 @@ func (s *ProxyStore) LabelValues(ctx context.Context, r *storepb.LabelValuesRequ
store := st
g.Go(func() error {
resp, err := store.LabelValues(gctx, &storepb.LabelValuesRequest{
Label: r.Label,
Label: r.Label,
PartialResponseDisabled: r.PartialResponseDisabled,
})
if err != nil {
Expand Down

0 comments on commit 57a58a7

Please sign in to comment.