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

Add configuration documentation generation tool #7916

Merged
merged 6 commits into from
Dec 14, 2022
Merged

Conversation

ssncferreira
Copy link
Contributor

@ssncferreira ssncferreira commented Dec 12, 2022

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:

  • _index.md
  • configuration flags registration in the code

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:

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

@github-actions github-actions bot added the type/docs Issues related to technical documentation; the Docs Squad uses this label across many repositories label Dec 12, 2022
@ssncferreira ssncferreira force-pushed the doc_gen_tool branch 2 times, most recently from 56fa19d to a1c1e83 Compare December 12, 2022 19:44
Copy link
Collaborator

@periklis periklis left a 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 🚀

Comment on lines +79 to +83
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)
Copy link
Collaborator

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?

Copy link
Contributor Author

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)

Copy link
Contributor

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.

Copy link
Contributor Author

@ssncferreira ssncferreira Dec 13, 2022

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

Comment on lines +89 to +90
CompactorHTTPClient compactor_client.HTTPConfig `yaml:"compactor_client,omitempty" doc:"hidden"`
CompactorGRPCClient compactor_client.GRPCConfig `yaml:"compactor_grpc_client,omitempty" doc:"hidden"`
Copy link
Collaborator

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.

Copy link
Contributor Author

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 👍

@ssncferreira ssncferreira force-pushed the doc_gen_tool branch 2 times, most recently from 160a0a0 to 5550cd6 Compare December 13, 2022 10:43
@ssncferreira
Copy link
Contributor Author

ssncferreira commented Dec 13, 2022

There are a couple of breaking changes on the CLI flags:

  • ruler.wal-cleaer.period typo in cleaner.
  • Storage types are registered with 2 duplicate prefixes. Example for gcs: common.storage.gcsgcs.bucketname. This PR changes this flag to common.storage.gcs.bucketname.
    Similarly to storage type bos, it was registered as common.storage.bosbaidubce. This PR changes the prefix to common.storage.bos for consistency.
    Edit: 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. (see comment Add configuration documentation generation tool #7916 (comment))

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) {
Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor Author

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

Copy link
Contributor

@dannykopping dannykopping left a 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"`
Copy link
Contributor

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

Comment on lines +79 to +83
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)
Copy link
Contributor

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) {
Copy link
Contributor

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

@grafanabot
Copy link
Collaborator

./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%

@ssncferreira ssncferreira marked this pull request as ready for review December 14, 2022 10:14
@ssncferreira ssncferreira requested a review from a team as a code owner December 14, 2022 10:14
@grafanabot
Copy link
Collaborator

./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%

@grafanabot
Copy link
Collaborator

./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%

Copy link
Contributor

@dannykopping dannykopping left a comment

Choose a reason for hiding this comment

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

LGTM!

@grafanabot
Copy link
Collaborator

./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%

Copy link
Contributor

@chaudum chaudum left a 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
Copy link
Contributor

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

Suggested change
## Printing Loki Config At Runtime
## Printing Loki config at runtime

Copy link
Contributor

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

Copy link
Contributor Author

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.")
Copy link
Contributor

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).

Suggested change
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.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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.")

@ssncferreira ssncferreira merged commit f93b91b into main Dec 14, 2022
@ssncferreira ssncferreira deleted the doc_gen_tool branch December 14, 2022 10:47
ssncferreira added a commit that referenced this pull request Dec 14, 2022
ssncferreira added a commit that referenced this pull request Dec 14, 2022
**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`
ssncferreira added a commit that referenced this pull request Dec 14, 2022
…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`
ssncferreira added a commit that referenced this pull request Dec 14, 2022
**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`
owen-d pushed a commit that referenced this pull request Jan 19, 2023
**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`
dannykopping pushed a commit that referenced this pull request Mar 22, 2023
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.
grafanabot pushed a commit that referenced this pull request Mar 22, 2023
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/XXL type/docs Issues related to technical documentation; the Docs Squad uses this label across many repositories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants