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

storeApi: add component information to gRPC's Info response (resolves #739) #750

Merged
merged 1 commit into from Feb 6, 2019
Merged

storeApi: add component information to gRPC's Info response (resolves #739) #750

merged 1 commit into from Feb 6, 2019

Conversation

adrien-f
Copy link
Member

@adrien-f adrien-f commented Jan 18, 2019

Signed-off-by: Adrien Fillon adrien.fillon@cdiscount.com

This PR aims to resolve #739.

Changes

*: Adds a set of enums for each components of Thanos
storeAPI: Adds a component field to Info's response

Verification

@adrien-f
Copy link
Member Author

Greetings everyone 👋

Before I go further on this PR, let me know if I take the right approach. I limited myself to active components, dunno if it's worth it to have some kind of Tool enum for the other CLI commands like the bucket command.

Also not an expert in Protobuf. And that multi-interface thing in component.go is hard to reason about (imho).

Cheers 🎉

@adrien-f
Copy link
Member Author

BTW, which UI version do you prefer ?

A:
stores_a

B:
stores_b

/cc @metalmatze @jojohappy

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 a lot!

You were sceptical of this component desing on previous description. Are you sold now or do you have specific objections? (: I feel it kind of fits well.

Overall I like the direction! LGTM. Some suggestions.

Thanks for 2 different options. I really like both.. But B) might be more readable (:

pkg/component/component.go Show resolved Hide resolved
pkg/store/storepb/rpc.proto Outdated Show resolved Hide resolved
cmd/thanos/sidecar.go Outdated Show resolved Hide resolved
pkg/component/component.go Show resolved Hide resolved
@adrien-f
Copy link
Member Author

adrien-f commented Jan 25, 2019

I've completed every components for now ! I went with Option B. Here are some screenshots:

capture d ecran 2019-01-25 a 18 34 38

capture d ecran 2019-01-25 a 18 36 53

capture d ecran 2019-01-25 a 18 52 03

One thing I'd like some input is this bit: https://github.com/Cdiscount/thanos/blob/767eaaaeb59f72dc2b705386627a8c8948a31452/pkg/query/storeset.go#L312

I initially went with updating the StoreSpec.Metadata call but that messed with Gossip and the gossipSpec.Metadata in cmd/thanos/query.go. Not sure if that's the right thing to do (c).

Things left to do:

  • Testing with a Gossip based cluster and a mixed one.
  • Re-Review some things

@bwplotka
Copy link
Member

Awesome, can we remove WIP from PR title? It should encourage reviewers more ;p

@bwplotka
Copy link
Member

Also some minor rebase would be nice.

"github.com/improbable-eng/thanos/pkg/store/storepb"
)

type StoreAPI interface {
Copy link
Member

Choose a reason for hiding this comment

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

Go wants comments like this for exported functions:

Suggested change
type StoreAPI interface {
// StoreAPI is ...
type StoreAPI interface {

https://blog.golang.org/godoc-documenting-go-code

Copy link
Member

Choose a reason for hiding this comment

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

Exaclty this ^

Copy link
Member

@metalmatze metalmatze left a comment

Choose a reason for hiding this comment

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

Code looks good to me. I like the option B you went with. Thanks for taking care of this! 👍

@bwplotka bwplotka mentioned this pull request Feb 1, 2019
3 tasks
@adrien-f adrien-f changed the title WIP: *: add component information to gRPC's Info response (resolves #739) storeApi: add component information to gRPC's Info response (resolves #739) Feb 1, 2019
@adrien-f
Copy link
Member Author

adrien-f commented Feb 1, 2019

That was some rebase from hell !

I'm pretty happy with how it looks 😄 Hope to add some more UI niceties soon !

dir, err := ioutil.TempDir("", "prometheus-test")
testutil.Ok(t, err)

// TODO: might be worth creating a `testutil.NewBucketStore()`
Copy link
Member

@GiedriusS GiedriusS Feb 2, 2019

Choose a reason for hiding this comment

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

I haven't actually executed this code but LGTM. Except for this comment - what do you mean by this? What would it do?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Well the only benefit would be to use shorter function instead of (single line anyway) NewBucketStore(nil, nil, nil, dir, 2e5, 2e5, false, 20).

Let's remove this comment and go with what it is here 👍

Copy link
Member

@jojohappy jojohappy left a comment

Choose a reason for hiding this comment

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

LGTM 👍 I totally like option B. Thanks a lot!

@adrien-f
Copy link
Member Author

adrien-f commented Feb 3, 2019

Errrr, I messed up the latest merge 😕 Will fix this later today.

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 and thanks!

Some nits related to commentary and formatting.

There is one potential to use embedding interfaces, not sure why you replicate method but we might have diamond problem: https://joaodlf.com/go-the-diamond-problem.html but I think we can go with this as well 👍

@@ -522,7 +523,7 @@ func runRule(
}
logger := log.With(logger, "component", "store")
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 fix this and put proper type here as well (:

@@ -193,7 +194,7 @@ func runRule(
peer cluster.Peer,
objStoreConfig *pathOrContent,
tsdbOpts *tsdb.Options,
component string,
component component.SourceStoreAPI,
Copy link
Member

Choose a reason for hiding this comment

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

There is no point for this argument... Let's just put use constant everywhere (:

@@ -77,7 +78,7 @@ func registerSidecar(m map[string]setupFunc, app *kingpin.Application, name stri
objStoreConfig,
peer,
rl,
name,
Copy link
Member

Choose a reason for hiding this comment

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

Same here - let's just put constant in place everywhere in sidecar - no point to dynamically eval this variable

pkg/component/component.go Show resolved Hide resolved
"github.com/improbable-eng/thanos/pkg/store/storepb"
)

// Component that implements gRPC StoreApi
Copy link
Member

Choose a reason for hiding this comment

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

So in Golang for public structs and methods needs to start with method or struct name (:

So here would be StoreAPI is an component that... (:

Not sure if it is written anywhere, but essentially golint (go get -u golang.org/x/lint/golint && golint ./pkg/component/....) will show you the guidance there. It is super strict and sometimes annoying so we don't use it in CI but for those struct and method comments it makes sense, so can we adjust comments in this file in this way? (:

Copy link
Member

Choose a reason for hiding this comment

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

And missing trailing period for all comments here (:

"github.com/improbable-eng/thanos/pkg/store/storepb"
)

type StoreAPI interface {
Copy link
Member

Choose a reason for hiding this comment

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

Exaclty this ^

// Component that implements gRPC StoreApi and produce blocks of metrics
type SourceStoreAPI interface {
implementsStoreAPI()
producesBlocks()
Copy link
Member

Choose a reason for hiding this comment

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

Again, we could use embedding here. For example:

type SourceStoreAPI interface {
    Source
    StoreAPI
}

Copy link
Member

Choose a reason for hiding this comment

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

But I guess it will cause diamond problem as described here: https://joaodlf.com/go-the-diamond-problem.html

(with String()) - that's fine then - let's leave your version as it is.

pkg/component/component.go Show resolved Hide resolved
message InfoResponse {
repeated Label labels = 1 [(gogoproto.nullable) = false];
int64 min_time = 2;
int64 max_time = 3;
StoreType storeType = 4;
Copy link
Member

Choose a reason for hiding this comment

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

nice, just formatting is off

dir, err := ioutil.TempDir("", "prometheus-test")
testutil.Ok(t, err)

// TODO: might be worth creating a `testutil.NewBucketStore()`
Copy link
Member

Choose a reason for hiding this comment

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

Well the only benefit would be to use shorter function instead of (single line anyway) NewBucketStore(nil, nil, nil, dir, 2e5, 2e5, false, 20).

Let's remove this comment and go with what it is here 👍

Signed-off-by: Adrien Fillon <adrien.fillon@cdiscount.com>
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!

@bwplotka bwplotka merged commit e1b0cb6 into thanos-io:master Feb 6, 2019
@bwplotka
Copy link
Member

bwplotka commented Feb 6, 2019

Thanks for this!

Now we need to think about something to fix that: #748

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show type of store on store overview page
5 participants