Skip to content

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

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

Merged
merged 1 commit into from
Jan 21, 2020
Merged

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

merged 1 commit into from
Jan 21, 2020

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.

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