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

*: Allow exposing multiple label-sets #1284

Merged
merged 6 commits into from
Jul 1, 2019

Conversation

brancz
Copy link
Member

@brancz brancz commented Jun 27, 2019

Changes

This PR adds that the Info gRPC service now exposes potentially multiple label-sets. For all store types except proxy this doesn't change anything for now, it just adds the currently single label-set as the only entry in the list of label-sets. The proxy type, from now exposes it's stores' labels merged with its configured selector.

I'd like to ask that the proxy.go changes are particularly carefully reviewed.

Verification

Adapted all tests and see them passing.

@squat @bwplotka @GiedriusS @povilasv @domgreen

Copy link
Member

@povilasv povilasv left a comment

Choose a reason for hiding this comment

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

Definetely add changelog entry as this breaks our interface. labels -> labelsets in InfoResponse proto.

Would be amazing to see more docs, explaining how the store matching works, does store has too much all the labelsets only one, etc? Potential use cases.

pkg/store/storepb/rpc.proto Show resolved Hide resolved
pkg/store/proxy.go Outdated Show resolved Hide resolved
Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Initial review (did not finish yet). Overall LGTM, some suggestions so far (:

Will continue later.

s.mtx.RLock()
defer s.mtx.RUnlock()
func (s *storeRef) Update(labelSets []storepb.LabelSet, minTime int64, maxTime int64) {
s.mtx.Lock()
Copy link
Member

Choose a reason for hiding this comment

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

👍

pkg/query/storeset.go Outdated Show resolved Hide resolved
pkg/store/storepb/rpc.proto Show resolved Hide resolved
pkg/store/storepb/rpc.proto Show resolved Hide resolved
test/e2e/rule_test.go Show resolved Hide resolved
pkg/query/storeset.go Outdated Show resolved Hide resolved
pkg/query/storeset.go Outdated Show resolved Hide resolved
pkg/store/tsdb.go Show resolved Hide resolved
pkg/query/storeset.go Outdated Show resolved Hide resolved
pkg/store/prometheus.go Outdated Show resolved Hide resolved
Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

I think there might be 2 major things to improve (let me know if I am wrong):

  • matching is quite odd, is AND intended?
  • I don't think we need fanout on Info

pkg/store/proxy.go Outdated Show resolved Hide resolved
pkg/store/proxy.go Outdated Show resolved Hide resolved
pkg/store/proxy.go Outdated Show resolved Hide resolved
pkg/store/proxy.go Outdated Show resolved Hide resolved
@@ -193,7 +266,7 @@ func (s *ProxyStore) Series(r *storepb.SeriesRequest, srv storepb.Store_SeriesSe

sc, err := st.Series(seriesCtx, r)
if err != nil {
storeID := fmt.Sprintf("%v", storepb.LabelsToString(st.Labels()))
storeID := storepb.LabelSetsToString(st.LabelSets())
Copy link
Member

Choose a reason for hiding this comment

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

👍

pkg/store/proxy.go Outdated Show resolved Hide resolved
pkg/store/storepb/custom.go Show resolved Hide resolved
pkg/store/storepb/rpc.proto Show resolved Hide resolved
@brancz brancz force-pushed the multi-labelsets branch 5 times, most recently from e900615 to c447905 Compare June 28, 2019 19:27
@brancz
Copy link
Member Author

brancz commented Jun 28, 2019

I believe I have addressed all comments and rebased the branch to resolve conflicts with master. Let me know what you think 🙂 . Overall this is in a much better shape than the first time around I think! I'm feeling much more comfortable with it now. Thanks for the reviews!

CHANGELOG.md Outdated
@@ -19,6 +19,8 @@ We use *breaking* word for marking changes that are not backward compatible (rel

- [#1248](https://github.com/improbable-eng/thanos/pull/1248) Add a web UI to show the state of remote storage.

- [#1284](https://github.com/improbable-eng/thanos/pull/1284) Add support for multiple label-sets in Info gRPC service. This deprecates the single `Labels` slice of the `InfoResponse`.
Copy link
Member

Choose a reason for hiding this comment

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

Let's mention maybe what's the plan on deprecation. It looks like breaking change, while it is not. Worth to add details on that otherwise users will be like Ok, but then all the components has to be upgraded to 0.6.0 if I use 0.6.0 Querier?

Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

LGTM, just very minor nits.

Thanks!

stores := s.stores()

if len(stores) == 0 {
res.MaxTime = math.MaxInt64
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure about this. I know there is not regression to previous version (same logic), but does this make sense? ;p
Let's leave the comment maybe? // Edge case: we have all of the data if there are no stores. and add some TODO.

Essentially not sure if we no store we should do either

  • max time = MaxInt64 and min time = maxInt64 as nothing is there.
    or
  • max time = MaxInt64 and min Time MinInt64 if we want to have whole range ;p

But we should not spend time on this in this PR I guess.

Copy link
Member Author

Choose a reason for hiding this comment

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

Would an issue be more appropriate than a TODO in code maybe?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm adding the "Edge case:" comment back and will open an issue to decide this as a follow up.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks, makes sense

res.MaxTime = MaxTime
res.MinTime = MinTime
res.MaxTime = maxTime
res.MinTime = minTime

for _, l := range s.selectorLabels {
Copy link
Member

Choose a reason for hiding this comment

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

I assume we are not removing selector Labels for now?

Copy link
Member Author

Choose a reason for hiding this comment

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

It somewhat depends on our decision around the changelog. If we decide all queriers must be >=v0.6.0 if any are, then this would be safe to remove.

Copy link
Member

Choose a reason for hiding this comment

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

👍 Let's leave for now


res.LabelSets = make([]storepb.LabelSet, 0, len(labelSets))
for _, v := range labelSets {
res.LabelSets = append(res.LabelSets, storepb.LabelSet{Labels: v})
Copy link
Member

Choose a reason for hiding this comment

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

Worth to mention on interface that sets are not sorted?

Copy link
Member Author

Choose a reason for hiding this comment

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

Added to the proto message and generated structs.

pkg/store/proxy.go Outdated Show resolved Hide resolved
pkg/store/proxy.go Outdated Show resolved Hide resolved
pkg/store/storepb/rpc.proto Show resolved Hide resolved
This is used for backward compatibility of the querier with store APIs
that don't expose LabelSet yet.
Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Thanks just one suggestion more - hopefully last one (:

@@ -32,14 +33,14 @@ type StoreSpec interface {
// If metadata call fails we assume that store is no longer accessible and we should not use it.
// NOTE: It is implementation responsibility to retry until context timeout, but a caller responsibility to manage
// given store connection.
Metadata(ctx context.Context, client storepb.StoreClient) (labels []storepb.Label, mint int64, maxt int64, err error)
Metadata(ctx context.Context, client storepb.StoreClient) (labelSets []storepb.LabelSet, labels []storepb.Label, mint int64, maxt int64, err error)
Copy link
Member

Choose a reason for hiding this comment

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

I don't really get why not just replacing with labelSets.

We can hide the compatibility logic internally, right?

s.mtx.RLock()
defer s.mtx.RUnlock()
func (s *storeRef) Update(labelSets []storepb.LabelSet, labels []storepb.Label, minTime int64, maxTime int64) {
if len(labelSets) == 0 && len(labels) > 0 {
Copy link
Member

Choose a reason for hiding this comment

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

I would hide it behind Metadata interface.

stores := s.stores()

if len(stores) == 0 {
res.MaxTime = math.MaxInt64
Copy link
Member

Choose a reason for hiding this comment

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

Thanks, makes sense

res.MaxTime = MaxTime
res.MinTime = MinTime
res.MaxTime = maxTime
res.MinTime = minTime

for _, l := range s.selectorLabels {
Copy link
Member

Choose a reason for hiding this comment

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

👍 Let's leave for now

@bwplotka
Copy link
Member

bwplotka commented Jul 1, 2019

Awesome! 🚢 it.

Thanks 👍

@bwplotka bwplotka merged commit 05f81a5 into thanos-io:master Jul 1, 2019
@brancz brancz deleted the multi-labelsets branch July 1, 2019 19:07
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.

3 participants