Fixes regression introduced by recent change to avoid double call to flag.Parse() #2012
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.FlagSet
returns 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.file
at first), and then config file parameter was not found.To actually find the
-config.file
parameter, 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.