Fixes regression introduced by recent change to avoid double call to flag.Parse()#2012
Merged
pracucci merged 1 commit intocortexproject:masterfrom Jan 21, 2020
pstibrany:fix-config-file-parsing
Merged
Fixes regression introduced by recent change to avoid double call to flag.Parse()#2012pracucci merged 1 commit intocortexproject:masterfrom pstibrany:fix-config-file-parsing
pracucci merged 1 commit intocortexproject:masterfrom
pstibrany:fix-config-file-parsing
Conversation
…flag.Parse() Signed-off-by: Peter Štibraný <peter.stibrany@grafana.com>
pracucci
approved these changes
Jan 21, 2020
Contributor
pracucci
left a comment
There was a problem hiding this comment.
LGTM. I tested with -config.file at the beginning and end of arguments, and now looks working as expected. Thanks for the quick fix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes regression introduced by #1997.
When using
flag.ContinueOnError,Parse()method on*flag.FlagSetreturns errors, instead of panicking or exiting the program.My assumption was that it actually continues, but that's not the case. When cortex was called with
./cortex -target=distributor -server.http-listen-port=8001 -server.grpc-listen-port=9001 -config.file=./config.yaml,Parse()method returned error on first unknown parameter (which is-target=...here, as we only look for-config.fileat first), and then config file parameter was not found.To actually find the
-config.fileparameter, we now call flag.Parse repeatedly with reduced set of arguments, until configFile is set to non-zero string or we run out of arguments.