-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
receive: Add ability to consume contents of the hashrings file directly #3121
Conversation
facacc8
to
cfb0bda
Compare
cfb0bda
to
f4b7c33
Compare
Looking forward to taking a close look at this 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! LGTM 💪 perfect.
a2222ce
to
b2f7761
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM from my side.
b2f7761
to
cedcac5
Compare
7e21dfd
to
81dbb29
Compare
@squat Thanks for the great review as always. I have addressed your concerns, could please take another look at it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it especially extra tests. But I think we can do better on pathOrContent API 🤗 Let's do it properly as it's quite flexible flag, so would be nice to have clean API.
cmd/thanos/receive.go
Outdated
}, func(error) { | ||
cancel() | ||
}) | ||
} else { | ||
// The Hashrings config file path is not given, so initialize using content.. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// The Hashrings config file path is not given, so initialize using content.. | |
// The Hashrings config file path is not given, so initialize using content. |
pkg/extflag/pathorcontent.go
Outdated
// Path returns the path of the given file that has passed to the flag. | ||
// It returns error if both a path and content are given. | ||
// It returns error if the required flag is set to true and path is empty. | ||
func (p *PathOrContent) Path() (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmmm...
So Content()
is a bit different semantically. We aim for Content to be always there unless flag is optional.
With Path.. we have one more case, of user not specifying path at al, but specifying content. While technically this method should be understandable there are so many cases to tests to check which of those 6 cases we have (content passed, path passed, filag not used) x2 (required or not)
While all of this we have also this important message that is hidden in terms of hashring file:
IF you specify via content it will be used. If specify via path it will be dynamically reloadable. There are 2 problems with this:
- This is surprising. We never reload content. How user can know we do it now? And let's say we are explicit we reload hashring. How user will know that other flags then hashrings are not dynamically reloadable?
- What if I want via path but don't want to dynamically reload? For example I want to put file, start receive and remove (for some reason). Maybe rare, but someone could be surprised this is not possible. Might other usecases as well.
I think we need to think this through. I have some ideas, but before I state them, maybe you have as well? 🤗 Do you see the problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is surprising. We never reload content. How user can know we do it now? And let's say we are explicit we reload hashring. How user will know that other flags then hashrings are not dynamically reloadable?
I understand the concern. Maybe overloading the PathOrContent
for the Receive's use case is not the best way.
Receive has a special way to handle the given path as you already mentioned. It initializes a watcher for the given path.
What if I want via path but don't want to dynamically reload? For example I want to put file, start receive and remove (for some reason). Maybe rare, but someone could be surprised this is not possible. Might other usecases as well.
This is a problem we already have. This PR shouldn't be aiming to solve this. However, I can add more documentation to clarify this behaviour.
How about rather than overloading the PathOrContent
, we implement dedicated logic in the receive. Specific to receive? Would this work? WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm what about, creating a second constructor?
So we can have:
something
orsomething-file
as one constructorsomething
andsomething-file
andsomething-reloadable-file
if you use another constructor
So receive will use latter (: Then we can actually embed file watching in the second constructor, directly in pathOrContent package 🤗
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea. I would love to work on it on a separate PR to introduce this feature in a more generalized form.
How about merging this PR as is and then creating an issue for it? As I told you I can work on it. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bwplotka As we talked off-line, do we have a consensus? Can we proceed with this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
YES! love it. Thanks!
9915bc7
to
3dad8ba
Compare
Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>
Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>
Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>
Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>
Simplify hasring configuration Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>
3dad8ba
to
996dad9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done with short term thing 👍🏽
It will have the same flag spec 🤗
Signed-off-by: Kemal Akkoyun kakkoyun@gmail.com
Fixes #3026.
Changes
--receive.hashrings
alternative toreceive.hashrings-file
flag (lower priority). Content of JSON file that contains the hashring configuration.Verification
make test-local
make test-e2e