Skip to content

Conversation

aknuds1
Copy link
Contributor

@aknuds1 aknuds1 commented Jan 21, 2022

What this PR does:
Implement configuration parameter categorization, via struct field tags. The tag key "category" is used to signal category, which should be one of the following:

  • basic
  • advanced
  • experimental

If the key isn't supplied, basic will be assumed (i.e., it's the default).

Two new flags are introduced, printing advanced and experimental help respectively:

  • -help-advanced
  • -help-experimental

Which issue(s) this PR fixes:

Checklist

  • Tests updated
  • [na] Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

Help output

  • -help (note that -compactor.block-ranges is hidden)

TODOs

  • Categorize remaining parameters (maybe for another PR?)
  • Add tests

@aknuds1 aknuds1 force-pushed the feat/categorize-flags branch from 258a5e8 to 697d1a8 Compare January 21, 2022 13:20
@osg-grafana osg-grafana added the type/docs Improvements or additions to documentation label Jan 21, 2022
@aknuds1 aknuds1 added the enhancement New feature or request label Jan 24, 2022
@aknuds1 aknuds1 force-pushed the feat/categorize-flags branch from 697d1a8 to aa38e00 Compare January 25, 2022 07:33
@aknuds1 aknuds1 changed the title WIP: Implement configuration parameter categorization Implement configuration parameter categorization Jan 25, 2022
@aknuds1 aknuds1 marked this pull request as ready for review January 25, 2022 08:57
@aknuds1 aknuds1 requested a review from a team January 25, 2022 08:58
@aknuds1 aknuds1 removed the type/docs Improvements or additions to documentation label Jan 25, 2022
@replay
Copy link
Contributor

replay commented Jan 25, 2022

I like the idea of categorizing the flags into basic, advanced and experimental, that should help to not overwhelm first-time users with options.

If I understand the current solution correctly then --help-advanced will only print the flags marked as "advanced" and --help-experimental will only print the flags marked as experimental. I'm wondering if it wouldn't make sense to treat this more like log levels where for example --help-advanced would give you the advanced help and also the "lower" levels, in this case basic, mixed together.

@simonswine
Copy link
Contributor

I would tend to agree with @replay. I think even only having two help flags might be sufficient:

--help: Show basic flags.
--help-all: Show basic, advanced and experimental flags.

As a new user you won't be exposed to the variety of flags we have today, but when you are advanced you can always use --help-all and grep through all flags available.

Wdyt?

@aknuds1
Copy link
Contributor Author

aknuds1 commented Jan 25, 2022

@replay @simonswine I would be OK with both of your suggestions.

@replay WDYT of what @simonswine suggests? I think I tend towards sympathizing with @simonswine's thinking, i.e. that one can easily grep through all options.

@replay
Copy link
Contributor

replay commented Jan 25, 2022

I agree, I think that the two options --help for basic options and --help-all for all options are probably sufficient to achieve the goal of not overwhelming basic users, and it makes it easy for everyone else to see/grep all the options.

@aknuds1
Copy link
Contributor Author

aknuds1 commented Jan 25, 2022

I agree, I think that the two options --help for basic options and --help-all for all options are probably sufficient to achieve the goal of not overwhelming basic users, and it makes it easy for everyone else to see/grep all the options.

@replay OK, I guess we're leaning towards changing to PR to implement the above scheme :) I'll just wait a bit to see what others say.

@aknuds1 aknuds1 force-pushed the feat/categorize-flags branch from f301f0a to dd341e6 Compare January 25, 2022 13:51
@aknuds1
Copy link
Contributor Author

aknuds1 commented Jan 25, 2022

I've implemented -help-all, removing -help-advanced and -help-experimental as suggested by @simonswine.

Also now prepending experimental flags with [experimental] as suggested by @pracucci.

Thanks for the feedback, everyone!

Copy link
Collaborator

@pracucci pracucci left a comment

Choose a reason for hiding this comment

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

Good job!

[not necessarily for this PR but I would be glad if you could consider it] I think my main concern is that there's no testing and we could break it without noticing it. Also seeing the impact of future changes may not be trivial. I'm wondering if we could adopt an approach like the auto-generated config: store the rendered version of it in the repo and have a check like check-doc in CI which ensures every PR changing config updates it too. We could build mimir and run both mimir -help and mimir -help-all storing their output in 2 respective files. When review any PR affecting config changes (or any change to the usage) we'll see the rendered files changed too.

@aknuds1
Copy link
Contributor Author

aknuds1 commented Jan 25, 2022

Good job!

[not necessarily for this PR but I would be glad if you could consider it] I think my main concern is that there's no testing and we could break it without noticing it. Also seeing the impact of future changes may not be trivial. I'm wondering if we could adopt an approach like the auto-generated config: store the rendered version of it in the repo and have a check like check-doc in CI which ensures every PR changing config updates it too. We could build mimir and run both mimir -help and mimir -help-all storing their output in 2 respective files. When review any PR affecting config changes (or any change to the usage) we'll see the rendered files changed too.

@pracucci I can add tests, I just wanted to gather feedback first.

Your suggestion regarding checking for help output regressions sounds like the Chromium testing strategy (regression testing based on reference text files) :D

@aknuds1 aknuds1 force-pushed the feat/categorize-flags branch from 7157391 to 0bbd263 Compare January 25, 2022 15:10
@aknuds1
Copy link
Contributor Author

aknuds1 commented Jan 26, 2022

Working on adding tests today.

@aknuds1 aknuds1 force-pushed the feat/categorize-flags branch 5 times, most recently from aff1318 to e87c41c Compare January 26, 2022 15:44
@aknuds1 aknuds1 requested a review from replay January 26, 2022 15:44
aknuds1 and others added 15 commits January 26, 2022 16:57
Signed-off-by: Arve Knudsen <[email protected]>
Co-authored-by: Mauro Stettler <[email protected]>
Signed-off-by: Arve Knudsen <[email protected]>
@aknuds1 aknuds1 force-pushed the feat/categorize-flags branch from e87c41c to 83b4e96 Compare January 26, 2022 15:57
Copy link
Collaborator

@pracucci pracucci left a comment

Choose a reason for hiding this comment

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

Good job, LGTM! It looks a good starting point to me. I would be happy to merge this PR as is and then start working on classifying flags in follow up PRs.

Signed-off-by: Arve Knudsen <[email protected]>
@aknuds1 aknuds1 force-pushed the feat/categorize-flags branch from 47cfa05 to 27633e8 Compare January 26, 2022 17:07
Copy link
Contributor

@replay replay left a comment

Choose a reason for hiding this comment

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

This looks good to me, good job!

I really like the new test which compares the generated help against one that has been committed to the repo, this will make it easy to visualize how a change in the code affects the generated output.

I would be happy to merge this PR as is and then start working on classifying flags in follow up PRs

I agree. But I wonder if we should try to define criteria based on which we decide which flags should be marked as advanced or experimental and commit that criteria to the docs? For example in docs/sources/contributing/design-patterns-and-conventions.md. I think without clear criteria there will almost certainly be inconsistency in the categorization, by defining the criteria early we can prevent such inconsistency.

How about:

Advanced:
A flag which is only required to tune Mimir for very specific scenarios, it should never be necessary to use an advanced flag to configure a Mimir cluster which stores less than 1M series and which uses a public object store like S3 or GCS.

Experimental:
A feature of which the Mimir team doesn't know or can reasonably assume that it has been used in any production environment for at least 3 months, and which isn't listed as Experimental in:

## Experimental features
.

Copy link
Contributor

@KMiller-Grafana KMiller-Grafana left a comment

Choose a reason for hiding this comment

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

I'm approving this, but hope you'll consider the changes I've suggested before merge.

@@ -95,24 +97,32 @@ func main() {
flag.IntVar(&blockProfileRate, "debug.block-profile-rate", 0, "Fraction of goroutine blocking events that are reported in the blocking profile. 1 to include every blocking event in the profile, 0 to disable.")
flag.BoolVar(&printVersion, "version", false, "Print application version and exit.")
flag.BoolVar(&printModules, "modules", false, "List available values that can be used as target.")
flag.BoolVar(&printHelp, "help", false, "Print basic help.")
flag.BoolVar(&printHelp, "h", false, "Print basic help.")
flag.BoolVar(&printHelpAll, "help-all", false, "Print help including also advanced and experimental flags.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure what to suggest. Configuration options are not the same as flags. Are they parameters? Knobs? Parameters is used elsewhere in user help output, so maybe do that here as well.

Suggested change
flag.BoolVar(&printHelpAll, "help-all", false, "Print help including also advanced and experimental flags.")
flag.BoolVar(&printHelpAll, "help-all", false, "Print help, also including advanced and experimental flags.")

Copy link
Contributor Author

@aknuds1 aknuds1 Jan 27, 2022

Choose a reason for hiding this comment

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

@KMiller-Grafana I use the term flags consequently as regards the CLI, since that's what they are in this context. They correspond to configuration parameters, but are concretely flags in this user interface.

For example, -help, -h and -help-all are all flags.

I haven't double checked if we're consequent in the CLI terminology elsewhere though, that's the most important thing.

flag.CommandLine.SetOutput(os.Stdout)
usage()
if err := flag.CommandLine.Parse(os.Args[1:]); err != nil {
fmt.Fprintln(flag.CommandLine.Output(), "Run with -help to get list of available parameters")
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you make this same substitution in the other lines that read the same?

Suggested change
fmt.Fprintln(flag.CommandLine.Output(), "Run with -help to get list of available parameters")
fmt.Fprintln(flag.CommandLine.Output(), "Run with -help to get a list of available parameters.")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@KMiller-Grafana this is actually carried over from old code. If we're to change it, I think it's best considered in its own PR.

Copy link
Contributor Author

@aknuds1 aknuds1 Jan 27, 2022

Choose a reason for hiding this comment

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

@KMiller-Grafana after reading this more closely, I think the current wording ("Run with -help to get list of available parameters") is the right one, since it's not just a list, but a certain list (the list of basic parameters). Changing it would make it more ambiguous to me at least, since it makes it sound as if there's some doubt as to what list would be produced.

Copy link
Contributor

Choose a reason for hiding this comment

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

I made my suggestion to make the phrase grammatically correct.

@aknuds1 My opinion: shoveling this off into another PR just created technical debt that no one will ever get to or implement. I'm currently your expert when it comes to documentation of anything related to Mimir configuration. I'm also your UI person for this effort. Please, since you've argued against what I know is an improvement, make the changes in another PR yourself, and don't lose the task.

Copy link
Contributor Author

@aknuds1 aknuds1 Jan 27, 2022

Choose a reason for hiding this comment

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

@KMiller-Grafana I already made another PR, which has been merged in the meantime.

@pracucci
Copy link
Collaborator

But I wonder if we should try to define criteria based on which we decide which flags should be marked as advanced or experimental and commit that criteria to the docs?

💯 agree. I know @09jvilla and team already did some work (I reviewed a classification proposal just yesterday) but I also missed a bit the rationale behind some classification. Given we're going public, I definitely agree on documenting the rationale in this doc so that we have a guideline to enforce it over time.

Going to merge this PR since the classification criteria doesn't block the foundation work done here.

@pracucci pracucci merged commit f2ca89c into main Jan 27, 2022
@pracucci pracucci deleted the feat/categorize-flags branch January 27, 2022 07:27
@pracucci
Copy link
Collaborator

I'm approving this, but hope you'll consider the changes I've suggested before merge.

Sorry! I totally missed the comment before merging. @aknuds1 can you address it in a follow up PR, please?

@aknuds1
Copy link
Contributor Author

aknuds1 commented Jan 27, 2022

@pracucci will do.

@osg-grafana osg-grafana added the type/docs Improvements or additions to documentation label Jan 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request type/docs Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants