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

avoid mutating config while parsing -config.file #2392

Merged
merged 4 commits into from
Aug 5, 2020

Conversation

owen-d
Copy link
Member

@owen-d owen-d commented Jul 22, 2020

Refactors our config loading to avoid accidentally mutating configs. Previously, in order to parse out the config.file flag, we'd have to call RegisterFlags + Parse on the Loki config struct and the global flagset. This plays poorly with slice flags. If they're defined as CLI flags but not in the YAML, they'll effectively get written twice into the config as multiple specifications of the flag appends.

Depends on cortexproject/cortex#2917
Fixes #2363

@owen-d owen-d mentioned this pull request Jul 27, 2020
@slim-bean
Copy link
Collaborator

is it possible to write a test for the case that triggered this? change seems fine, config always seems harder than it needs to be.

@pull-request-size pull-request-size bot added size/L and removed size/M labels Aug 4, 2020
@codecov-commenter
Copy link

Codecov Report

Merging #2392 into master will increase coverage by 0.02%.
The diff coverage is 45.83%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2392      +/-   ##
==========================================
+ Coverage   62.80%   62.83%   +0.02%     
==========================================
  Files         162      162              
  Lines       13966    13972       +6     
==========================================
+ Hits         8772     8779       +7     
+ Misses       4512     4506       -6     
- Partials      682      687       +5     
Impacted Files Coverage Δ
pkg/cfg/cfg.go 50.00% <0.00%> (ø)
pkg/logcli/query/query.go 0.00% <0.00%> (ø)
pkg/cfg/files.go 33.33% <55.00%> (+26.01%) ⬆️
pkg/querier/queryrange/downstreamer.go 95.87% <0.00%> (-2.07%) ⬇️
pkg/promtail/targets/file/filetarget.go 67.85% <0.00%> (-1.79%) ⬇️
pkg/logql/evaluator.go 92.47% <0.00%> (-0.41%) ⬇️
pkg/promtail/targets/file/tailer.go 78.40% <0.00%> (+2.27%) ⬆️

@owen-d owen-d marked this pull request as ready for review August 5, 2020 00:55
Copy link
Collaborator

@slim-bean slim-bean left a comment

Choose a reason for hiding this comment

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

LGTM

@slim-bean slim-bean merged commit 7530bf6 into grafana:master Aug 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using flag -memberlist.bind-addr results in duplicates in config
3 participants