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

cmd/thanos: Refactor run*(...) functions. #2248

Closed
bwplotka opened this issue Mar 10, 2020 · 30 comments
Closed

cmd/thanos: Refactor run*(...) functions. #2248

bwplotka opened this issue Mar 10, 2020 · 30 comments

Comments

@bwplotka
Copy link
Member

Hi 👋

Right now all our components can be run as a single commands. We do this via those ugly run functions with a sometimes a large number of arguments (one per each flag). e.g. https://github.com/thanos-io/thanos/blob/master/cmd/thanos/query.go#L132 It would be nice to fix this while preserving flags. The short fix would be to create config structs for each command that will be populated by flags, and then pass it to run functions?

AC:

  • No more functions with 20+ arguments in Thanos.
@bwplotka
Copy link
Member Author

Wonder if this helps https://github.com/peterbourgon/ff

@bwplotka
Copy link
Member Author

bwplotka commented Mar 10, 2020

cc@s-urbaniak as you were complaining about this 😈

@philipgough
Copy link
Contributor

@bwplotka I don't mind taking a stab at this if thats ok

@bwplotka
Copy link
Member Author

Sure @philipgough ❤️

Let us know here @philipgough what would be idea of end look .e.g. how you plan to achieve this. (:

@philipgough
Copy link
Contributor

@bwplotka I did some work on the sidecar component only to get some feedback. See #2267

Basically, the idea I had was to decompose into smaller structs with related config and compose the config for the component from these.

Config structs are built by passing all flags into a func. The benefit here is that we wouldn't need to duplicate this info in each component, the downside (I haven't checked if its required) is the lack of ability to customise defaults in each component. Should the defaults always be the same?

I took a look at the package you linked and while it would probably work, would require a change from kingpin lib to flag package in stdlib. Maybe this is worth considering but I would have thought unlikely?

I didn't see that the kingpin library had a way to populate struct fields directly during parse unfortunately

@stale
Copy link

stale bot commented Apr 12, 2020

This issue/PR has been automatically marked as stale because it has not had recent activity. Please comment on status otherwise the issue will be closed in a week. Thank you for your contributions.

@stale stale bot added the stale label Apr 12, 2020
@bwplotka
Copy link
Member Author

bwplotka commented Apr 12, 2020 via email

@stale
Copy link

stale bot commented May 12, 2020

Hello 👋 Looks like there was no activity on this issue for last 30 days.
Do you mind updating us on the status? Is this still reproducible or needed? If yes, just comment on this PR or push a commit. Thanks! 🤗
If there will be no activity for next week, this issue will be closed (we can always reopen an issue if we need!). Alternatively, use remind command if you wish to be reminded at some point in future.

@soniasingla
Copy link
Contributor

@bwplotka i would like to play with this bug 😺

@philipgough
Copy link
Contributor

@soniasingla I have some completed already but feel free to take any of the others. I am working through query at the moment, compact and sidecar are done.

@stale
Copy link

stale bot commented Jul 2, 2020

Hello 👋 Looks like there was no activity on this issue for last 30 days.
Do you mind updating us on the status? Is this still reproducible or needed? If yes, just comment on this PR or push a commit. Thanks! 🤗
If there will be no activity for next week, this issue will be closed (we can always reopen an issue if we need!). Alternatively, use remind command if you wish to be reminded at some point in future.

@stale stale bot added the stale label Jul 2, 2020
@onprem
Copy link
Member

onprem commented Jul 3, 2020

Still valid

@stale stale bot removed the stale label Jul 3, 2020
@stale
Copy link

stale bot commented Aug 2, 2020

Hello 👋 Looks like there was no activity on this issue for last 30 days.
Do you mind updating us on the status? Is this still reproducible or needed? If yes, just comment on this PR or push a commit. Thanks! 🤗
If there will be no activity for next week, this issue will be closed (we can always reopen an issue if we need!). Alternatively, use remind command if you wish to be reminded at some point in future.

@stale stale bot added the stale label Aug 2, 2020
@stale
Copy link

stale bot commented Aug 9, 2020

Closing for now as promised, let us know if you need this to be reopened! 🤗

@stale stale bot closed this as completed Aug 9, 2020
@stale stale bot removed the stale label Feb 2, 2021
@MalloZup
Copy link
Contributor

MalloZup commented Feb 2, 2021

ack 👾

@bwplotka
Copy link
Member Author

Maybe @idoqo, you want help here? Sounds like it's defined and we need this badly 🤗

@bwplotka
Copy link
Member Author

I think querier, is almost done by @MalloZup , but let's look on other components if we can do the similar change as #3771 (review)

@idoqo
Copy link
Contributor

idoqo commented Mar 25, 2021

While implementing the config struct for ruler, I noticed some advantage in the current approach (using the run* methods) and I'm not sure how to apply them to the "config structs" method yet.

Using the run* methods as in

func runRule(
), we can figure all the flags that are applicable to a component.

Abstracting those parameters into config structs could take that away for instance: shipperConfig has four fields, but ruler only uses allowOutOfOrderUpload (i.e., shipper.allow-out-of-order-uploads). I feel like passing shipperConfig as a struct field for any config will imply that it accepts all four flags which is wrong.

@someshkoli
Copy link
Contributor

someshkoli commented Apr 14, 2021

Did similar refactoring for store 🤔 #4061

@stale
Copy link

stale bot commented Jun 16, 2021

Hello 👋 Looks like there was no activity on this issue for the last two months.
Do you mind updating us on the status? Is this still reproducible or needed? If yes, just comment on this PR or push a commit. Thanks! 🤗
If there will be no activity in the next two weeks, this issue will be closed (we can always reopen an issue if we need!). Alternatively, use remind command if you wish to be reminded at some point in future.

@stale stale bot added the stale label Jun 16, 2021
@stale
Copy link

stale bot commented Jun 30, 2021

Closing for now as promised, let us know if you need this to be reopened! 🤗

@stale stale bot closed this as completed Jun 30, 2021
@onprem onprem reopened this Jun 30, 2021
@stale stale bot removed the stale label Jun 30, 2021
@stale
Copy link

stale bot commented Sep 3, 2021

Hello 👋 Looks like there was no activity on this issue for the last two months.
Do you mind updating us on the status? Is this still reproducible or needed? If yes, just comment on this PR or push a commit. Thanks! 🤗
If there will be no activity in the next two weeks, this issue will be closed (we can always reopen an issue if we need!). Alternatively, use remind command if you wish to be reminded at some point in future.

@stale stale bot added the stale label Sep 3, 2021
@metonymic-smokey
Copy link
Contributor

Are there any commands left to complete?
Wanted to take a stab at it since it's a good first issue

@stale
Copy link

stale bot commented Jan 9, 2022

Hello 👋 Looks like there was no activity on this issue for the last two months.
Do you mind updating us on the status? Is this still reproducible or needed? If yes, just comment on this PR or push a commit. Thanks! 🤗
If there will be no activity in the next two weeks, this issue will be closed (we can always reopen an issue if we need!). Alternatively, use remind command if you wish to be reminded at some point in future.

@stale stale bot added the stale label Jan 9, 2022
@yeya24
Copy link
Contributor

yeya24 commented Jan 10, 2022

Still valid

@stale stale bot removed the stale label Jan 10, 2022
@stale
Copy link

stale bot commented Apr 16, 2022

Hello 👋 Looks like there was no activity on this issue for the last two months.
Do you mind updating us on the status? Is this still reproducible or needed? If yes, just comment on this PR or push a commit. Thanks! 🤗
If there will be no activity in the next two weeks, this issue will be closed (we can always reopen an issue if we need!). Alternatively, use remind command if you wish to be reminded at some point in future.

@stale stale bot added the stale label Apr 16, 2022
@stale
Copy link

stale bot commented Apr 30, 2022

Closing for now as promised, let us know if you need this to be reopened! 🤗

@stale stale bot closed this as completed Apr 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants