-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Add configuration documentation generation tool #7916
Conversation
56fa19d
to
a1c1e83
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.
Couple of things that I noticed. Great piece of work! Thank you so much 🚀
s.S3.RegisterFlagsWithPrefix(prefix, f) | ||
s.GCS.RegisterFlagsWithPrefix(prefix, f) | ||
s.Azure.RegisterFlagsWithPrefix(prefix, f) | ||
s.Swift.RegisterFlagsWithPrefix(prefix, f) | ||
s.BOS.RegisterFlagsWithPrefix(prefix, f) |
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 looks like a breaking change that needs extra mention in the backlog, right?
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, this is a breaking change to the CLI flags, because these were registered incorrectly. Not sure what the best course of action is here 😕 See comment: #7916 (comment)
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 think for the sake of BC, we should keep the old flags and put a deprecation notice in the upgrade guide, and create an issue for v3.0 to remove these deprecated flags.
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.
As discussed internally via slack, this is not a breaking change because the CLI flags with the prefix common.storage
are not yet available to the default flag system. These are only set on the throwaway flag system to allow for common config application logic.
However, in order to be able to generate the documentation for these flags, they need to be set on the default flag system: https://github.com/grafana/loki/pull/7916/files#diff-5789ed7c47e1cf4394cef6ad3bc4aaea1af3552e930b0420703708e6bd7d2c89R54-R57
CompactorHTTPClient compactor_client.HTTPConfig `yaml:"compactor_client,omitempty" doc:"hidden"` | ||
CompactorGRPCClient compactor_client.GRPCConfig `yaml:"compactor_grpc_client,omitempty" doc:"hidden"` |
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.
Why are these clients hidden? At least the GRPC client should be visible for users to configure TLS settings.
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.
These flags were added recently and were still not yet documented in the _index.md
file. Therefore, added the hidden flag for now. Nevertheless, will remove it in a follow-up PR in order to generate the documentation associated 👍
160a0a0
to
5550cd6
Compare
5550cd6
to
754d6f8
Compare
There are a couple of breaking changes on the CLI flags:
What is the best course of action here? Should we keep the previous flags, deprecate them and create new ones? |
@@ -14,7 +15,7 @@ type Config struct { | |||
Period time.Duration `yaml:"period,omitempty"` | |||
} | |||
|
|||
func (c Config) RegisterFlags(f *flag.FlagSet) { | |||
func (c *Config) RegisterFlags(f *flag.FlagSet) { |
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 pointer in config was missing, meaning that the default values for the variables were not taken into account. This might affect deployments using the ruler WAL cleaner config without any values defined.
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 think we should add an item to the upgrade guide about 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.
Upgrade guide makes sense 👍 Will address this in a follow-up PR to avoid increasing the size and review of this one
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.
Amazing work @ssncferreira! Thanks for taking on this very detail-oriented and labour-intensive task.
This PR is obviously too big to review closely, but generally everything LGTM. I think we need to add some upgrade notes but besides that I'm happy. So glad we have this now!!
@@ -113,7 +113,7 @@ type Querier interface { | |||
type EngineOpts struct { | |||
// TODO: remove this after next release. | |||
// Timeout for queries execution | |||
Timeout time.Duration `yaml:"timeout"` | |||
Timeout time.Duration `yaml:"timeout" doc:"deprecated"` |
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.
Possible enhancement for later: add a deprecated
flag so we can easily identify these
s.S3.RegisterFlagsWithPrefix(prefix, f) | ||
s.GCS.RegisterFlagsWithPrefix(prefix, f) | ||
s.Azure.RegisterFlagsWithPrefix(prefix, f) | ||
s.Swift.RegisterFlagsWithPrefix(prefix, f) | ||
s.BOS.RegisterFlagsWithPrefix(prefix, f) |
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 think for the sake of BC, we should keep the old flags and put a deprecation notice in the upgrade guide, and create an issue for v3.0 to remove these deprecated flags.
@@ -14,7 +15,7 @@ type Config struct { | |||
Period time.Duration `yaml:"period,omitempty"` | |||
} | |||
|
|||
func (c Config) RegisterFlags(f *flag.FlagSet) { | |||
func (c *Config) RegisterFlags(f *flag.FlagSet) { |
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 think we should add an item to the upgrade guide about this
./tools/diff_coverage.sh ../loki-target-branch/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell. + ingester 0%
+ distributor 0%
+ querier 0%
+ querier/queryrange 0%
+ iter 0%
+ storage 0%
+ chunkenc 0%
+ logql 0%
+ loki 0% |
6c031c7
to
cc52fa4
Compare
./tools/diff_coverage.sh ../loki-target-branch/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell. + ingester 0%
+ distributor 0%
+ querier 0%
+ querier/queryrange 0%
+ iter 0%
+ storage 0%
+ chunkenc 0%
+ logql 0%
+ loki 0% |
./tools/diff_coverage.sh ../loki-target-branch/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell. + ingester 0%
+ distributor 0%
+ querier 0%
+ querier/queryrange 0%
+ iter 0%
+ storage 0%
+ chunkenc 0%
+ logql 0%
+ loki 0% |
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!
./tools/diff_coverage.sh ../loki-target-branch/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell. + ingester 0%
+ distributor 0%
+ querier 0%
+ querier/queryrange 0.1%
+ iter 0%
+ storage 0%
+ chunkenc 0%
+ logql 0%
+ loki 0% |
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.
Great job! A few nits, but these should not block you.
|
||
Configuration examples can be found in the [Configuration Examples](examples/) document. | ||
|
||
## Printing Loki Config At Runtime |
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 think we use sentence case for titles
## Printing Loki Config At Runtime | |
## Printing Loki config at runtime |
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.
See also other headlines in this document
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.
👍 sounds good. Will address these comments in a separate PR
@@ -40,14 +40,14 @@ func (cfg *WALConfig) Validate() error { | |||
|
|||
// RegisterFlags adds the flags required to config this to the given FlagSet | |||
func (cfg *WALConfig) RegisterFlags(f *flag.FlagSet) { | |||
f.StringVar(&cfg.Dir, "ingester.wal-dir", "wal", "Directory to store the WAL and/or recover from WAL.") | |||
f.StringVar(&cfg.Dir, "ingester.wal-dir", "wal", "Directory where the WAL data should be stored and/or recovered from.") |
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.
It's not a suggestion (should) but a fact (is).
f.StringVar(&cfg.Dir, "ingester.wal-dir", "wal", "Directory where the WAL data should be stored and/or recovered from.") | |
f.StringVar(&cfg.Dir, "ingester.wal-dir", "wal", "Directory where the WAL data is stored and/or recovered from.") |
} | ||
|
||
// RegisterFlags register flags. | ||
func (cfg *Config) RegisterFlags(f *flag.FlagSet) { | ||
cfg.Engine.RegisterFlagsWithPrefix("querier", f) | ||
f.DurationVar(&cfg.TailMaxDuration, "querier.tail-max-duration", 1*time.Hour, "Limit the duration for which live tailing request would be served") | ||
f.DurationVar(&cfg.TailMaxDuration, "querier.tail-max-duration", 1*time.Hour, "Maximum duration for which the live tailing requests should be served.") |
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.
f.DurationVar(&cfg.TailMaxDuration, "querier.tail-max-duration", 1*time.Hour, "Maximum duration for which the live tailing requests should be served.") | |
f.DurationVar(&cfg.TailMaxDuration, "querier.tail-max-duration", 1*time.Hour, "Maximum duration for which the live tailing requests are served.") |
f.StringVar(&cfg.RulePath, "ruler.rule-path", "/rules", "file path to store temporary rule files for the prometheus rule managers") | ||
f.BoolVar(&cfg.EnableAPI, "experimental.ruler.enable-api", false, "Enable the ruler api") | ||
f.StringVar(&cfg.RulePath, "ruler.rule-path", "/rules", "File path to store temporary rule files.") | ||
f.BoolVar(&cfg.EnableAPI, "experimental.ruler.enable-api", false, "Enable the ruler api.") |
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.
f.BoolVar(&cfg.EnableAPI, "experimental.ruler.enable-api", false, "Enable the ruler api.") | |
f.BoolVar(&cfg.EnableAPI, "experimental.ruler.enable-api", false, "Enable the ruler API.") |
@@ -31,10 +31,10 @@ func (c *Config) RegisterFlags(f *flag.FlagSet) { | |||
c.WALCleaner.RegisterFlags(f) | |||
|
|||
// TODO(owen-d, 3.0.0): remove deprecated experimental prefix in Cortex if they'll accept it. | |||
f.BoolVar(&c.Config.EnableAPI, "ruler.enable-api", true, "Enable the ruler api") | |||
f.BoolVar(&c.Config.EnableAPI, "ruler.enable-api", true, "Enable the ruler api.") |
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.
f.BoolVar(&c.Config.EnableAPI, "ruler.enable-api", true, "Enable the ruler api.") | |
f.BoolVar(&c.Config.EnableAPI, "ruler.enable-api", true, "Enable the ruler API.") |
**What this PR does / why we need it**: Fix documentation typos from #7916 (review) **Which issue(s) this PR fixes**: Fixes #7916 (review) **Special notes for your reviewer**: **Checklist** - [ ] Reviewed the `CONTRIBUTING.md` guide - [ ] Documentation added - [ ] Tests updated - [ ] `CHANGELOG.md` updated - [ ] Changes that require user attention or interaction to upgrade are documented in `docs/sources/upgrading/_index.md`
…er.wal-cleaner.period (#7937) **What this PR does / why we need it**: Deprecate CLI flag `-ruler.wal-cleaer.period` in favor of CLI flag `-ruler.wal-cleaner.period`. **Which issue(s) this PR fixes**: Fixes #7916 (comment) and #7916 (comment) **NOTE:** correctly registring the `ruler.wal-cleaner` configuration flags is not a breaking change and doesn't require an upgrade guide, because the ruler WAL cleaner initialization code already guarantees that the default values are used: https://github.com/grafana/loki/blob/c71620ae9437aa23142cdc410115f28ae8f29997/pkg/ruler/storage/cleaner/cleaner.go#L76-L101 **Special notes for your reviewer**: **Checklist** - [x] Reviewed the `CONTRIBUTING.md` guide - [x] Documentation added - [ ] Tests updated - [x] `CHANGELOG.md` updated - [x] Changes that require user attention or interaction to upgrade are documented in `docs/sources/upgrading/_index.md`
**What this PR does / why we need it**: Follow up from PR: #7916 to add a CI step to check if the configuration flag documentation file `doc/sources/configuration/_index.md` was generated successfully. Requirements: * CI `check` pipeline should fail if the documentation file is updated manually * CI `check` pipeline should fail if registration flags are changed in the code, but the documentation file is not generated. **Which issue(s) this PR fixes**: Fixes https://github.com/grafana/loki-private/issues/83 **Special notes for your reviewer**: **Checklist** - [ ] Reviewed the `CONTRIBUTING.md` guide - [ ] Documentation added - [ ] Tests updated - [x] `CHANGELOG.md` updated - [ ] Changes that require user attention or interaction to upgrade are documented in `docs/sources/upgrading/_index.md`
**What this PR does / why we need it**: PR #7916 which introduced the documentation automation tool for Loki's configuration values, incorrectly removed the last sections of the documentation. This PR introduces them accordingly. **Checklist** - [ ] Reviewed the [`CONTRIBUTING.md`](https://github.com/grafana/loki/blob/main/CONTRIBUTING.md) guide (**required**) - [x] Documentation added - [ ] Tests updated - [ ] `CHANGELOG.md` updated - [ ] Changes that require user attention or interaction to upgrade are documented in `docs/sources/upgrading/_index.md`
With the addition of the [config generation tool](#7916), a comment prefix was added for all cache types: `Cache config for index entry writing.` https://grafana.com/docs/loki/next/configuration/#cache_config This appears in the description of each cache config option, and is misleading.
With the addition of the [config generation tool](#7916), a comment prefix was added for all cache types: `Cache config for index entry writing.` https://grafana.com/docs/loki/next/configuration/#cache_config This appears in the description of each cache config option, and is misleading. (cherry picked from commit 2d93952)
What this PR does / why we need it:
Add a tool to generate configuration flags documentation based on the flags properties defined on registration on the code. This tool is based on the Mimir doc generation tool and adapted according to Loki configuration specifications.
Prior to this PR, the configuration flags documentation was dispersed across two sources:
This meant that there was no single source of truth.
In this PR, the previous
_index.md
file is replaced with the new file generated by the tool.The next step includes adding a CI step that validates if the _index.md file was generated according to the flags settings. This will be done in a follow-up PR.
NOTE: this is not a documentation update PR. Apart from some minor typo fixes, the documentation changes on the code, were copied from the
_index.md
file.Which issue(s) this PR fixes:
Fixes https://github.com/grafana/loki-private/issues/83
Special notes for your reviewer:
Files:
loki/pkg
directory files updated with up-to-date documentation from_index.md
fileChecklist
CONTRIBUTING.md
guideCHANGELOG.md
updateddocs/sources/upgrading/_index.md