Skip to content

Fixes regression introduced by recent change to avoid double call to flag.Parse()#2012

Merged
pracucci merged 1 commit intocortexproject:masterfrom
pstibrany:fix-config-file-parsing
Jan 21, 2020
Merged

Fixes regression introduced by recent change to avoid double call to flag.Parse()#2012
pracucci merged 1 commit intocortexproject:masterfrom
pstibrany:fix-config-file-parsing

Conversation

@pstibrany
Copy link
Contributor

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.

…flag.Parse()

Signed-off-by: Peter Štibraný <peter.stibrany@grafana.com>
Copy link
Contributor

@jtlisi jtlisi left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@pracucci pracucci left a comment

Choose a reason for hiding this comment

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

LGTM. I tested with -config.file at the beginning and end of arguments, and now looks working as expected. Thanks for the quick fix.

@pracucci pracucci merged commit 56bd221 into cortexproject:master Jan 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants