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

pkg/flags: warns on shadowed environment variable flags #8385

Merged
merged 1 commit into from
Aug 14, 2017

Conversation

gyuho
Copy link
Contributor

@gyuho gyuho commented Aug 9, 2017

Address #8380.

export ETCD_NAME=aaaaa
./bin/etcd --name bbb
2017-08-09 14:18:11.061895 W | etcdmain: recognized environment variable ETCD_NAME, but unused: shadowed by corresponding flag

export ETCDCTL_ENDPOINTS=aaaaa.com
ETCDCTL_API=3 ./bin/etcdctl endpoint health --endpoints=bbb.com
2017-08-09 14:18:11.061895 W | pkg/flags: recognized environment variable ETCDCTL_ENDPOINTS, but unused: shadowed by corresponding flag


// WithNoConflict configures no-conflict mode.
// Expects error on conflicting flags.
func WithNoConflict() OpOption {
Copy link
Contributor

Choose a reason for hiding this comment

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

is it worth making this optional? I feel like it should always error out on shadowing

@@ -118,13 +127,18 @@ func verifyEnv(prefix string, usedEnvKey, alreadySet map[string]bool) {
continue
}
if alreadySet[kv[0]] {
plog.Infof("recognized environment variable %s, but unused: shadowed by corresponding flag ", kv[0])
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be staged as a deprecated warning in 3.3 and then finally fully error out in 3.4?

@gyuho gyuho added the WIP label Aug 9, 2017
@gyuho gyuho force-pushed the shadowed-environment-variables branch from 34319bc to 195744a Compare August 9, 2017 22:59
@gyuho gyuho changed the title *: error on shadowed environment variables pkg/flags: warns on shadowed environment variable flags Aug 9, 2017
@gyuho gyuho removed the WIP label Aug 10, 2017
@heyitsanthony
Copy link
Contributor

Is there any historical reason why shadowing is only a warning instead of fataling? I want to clamp down on etcd misconfigurations that have environment variables + flags defined, but this will also kill etcd for init setups that work by coincidence. /cc @xiang90

@gyuho gyuho added the WIP label Aug 10, 2017
@gyuho
Copy link
Contributor Author

gyuho commented Aug 10, 2017

+1 for just fataling on shadowed variables

@gyuho
Copy link
Contributor Author

gyuho commented Aug 14, 2017

@heyitsanthony Discussed with @xiang90 to keep it as warning for 3.3.
We don't remember why we did not fatal in the very first place.
Any thoughts?

@xiang90
Copy link
Contributor

xiang90 commented Aug 14, 2017

@gyuho We cannot panic users to keep this backward compatible. Or users might suddenly fail restarting etcd due to shadowing.

@heyitsanthony
Copy link
Contributor

OK, shadowing should be considered a misconfiguration? If so, this upgraded warning message is good to merge.

I couldn't come up with any compelling reasons for why anyone would want shadowing besides backwards compat. Is 3.4 good for fatal or should it be deferred to later?

@gyuho gyuho merged commit f1509a1 into etcd-io:master Aug 14, 2017
@gyuho gyuho deleted the shadowed-environment-variables branch August 15, 2017 00:01
@gyuho gyuho removed the WIP label Aug 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants