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

embed: warns about empty hosts in advertise urls #8384

Merged
merged 1 commit into from
Aug 11, 2017

Conversation

gyuho
Copy link
Contributor

@gyuho gyuho commented Aug 9, 2017

Address #8379.

./bin/etcd --listen-client-urls=http://127.0.0.1:2379 --advertise-client-urls=http://$SPELEDOK:2379

2017-08-09 13:34:52.220844 E | etcdmain: error verifying flags, unexpected empty host (http://:2379). See 'etcd --help'.

@codecov-io
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (master@0441345). Click here to learn what that means.
The diff coverage is 33.33%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #8384   +/-   ##
=========================================
  Coverage          ?   76.97%           
=========================================
  Files             ?      353           
  Lines             ?    28127           
  Branches          ?        0           
=========================================
  Hits              ?    21652           
  Misses            ?     4943           
  Partials          ?     1532
Impacted Files Coverage Δ
embed/config.go 66.19% <33.33%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0441345...a5dc6ed. Read the comment docs.

@heyitsanthony
Copy link
Contributor

I tried some empty host url abuse.

./etcd defaults:

$ ETCDCTL_API=3 ./bin/etcdctl --endpoints=http://:2379 endpoint status
http://:2379, 8e9e05c52164694d, 3.2.0+git, 16 kB, true, 10, 20

fails because of IP check:

$ ./bin/etcd --listen-client-urls=http://:2379 --advertise-client-urls=http://:2379
etcdmain: error verifying flags, expected IP in URL for binding (http://:2379). 

(fixed by this patch):

$ ./bin/etcd --listen-client-urls=http://0.0.0.0:2379 --advertise-client-urls=http://:2379

Does anyone use the empty host => any address behavior? A workaround like this seems tempting:

$ ETCDCTL_API=3 ./bin/etcdctl --endpoints=http://0.0.0.0:2379 endpoint status
http://0.0.0.0:2379, 8e9e05c52164694d, 3.2.0+git, 16 kB, true, 12, 24

but that only binds to any ipv4 address instead of any address.

On the other hand, empty hosts fail the curl sanity test:

$ curl http://:2379/
curl: (6) Could not resolve host: 
$ curl http://localhost:2379/health
{"health":true}
$ wget http://:2379/health
http://:2379/health: Invalid host name.

If etcd is advertising a client address curl can't parse, that must be broken. Maybe someone somewhere somehow relies on this though. Can this be a warning in 3.3 then a full error/exit in 3.4?

@gyuho gyuho added the WIP label Aug 10, 2017
@gyuho gyuho removed the WIP label Aug 10, 2017
@gyuho gyuho changed the title embed: check empty hosts in advertise urls embed: warns about empty hosts in advertise urls Aug 10, 2017
@gyuho
Copy link
Contributor Author

gyuho commented Aug 10, 2017

@heyitsanthony PTAL. Now just logs warnings.

Thanks.

embed/config.go Outdated
@@ -299,6 +299,14 @@ func (cfg *Config) Validate() error {
if err := checkBindURLs(cfg.ListenMetricsUrls); err != nil {
return err
}
if err := checkHostURLs(cfg.APUrls); err != nil {
// TODO: return err in v3.4
plog.Warning(err)
Copy link
Contributor

Choose a reason for hiding this comment

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

should these say something like "advertise-peer-urls %q is deprecated (%v)" if the intent is to eventually exit out? warning with only the error doesn't seem clear enough

@gyuho gyuho force-pushed the advertise-url branch 3 times, most recently from 4a0fea8 to 6ad85d3 Compare August 10, 2017 19:28
@gyuho
Copy link
Contributor Author

gyuho commented Aug 10, 2017

@heyitsanthony PTAL. Now

./bin/etcd --listen-client-urls=http://127.0.0.1:2379 --advertise-client-urls=http://$SPELEDOK:2379
2017-08-10 12:33:58.211006 W | embed: advertise-client-urls "http://:2379" is deprecated (unexpected empty host (http://:2379))

Thanks.

Copy link
Contributor

@heyitsanthony heyitsanthony left a comment

Choose a reason for hiding this comment

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

lgtm thanks

@gyuho gyuho merged commit 8df2132 into etcd-io:master Aug 11, 2017
@gyuho gyuho deleted the advertise-url branch August 11, 2017 17:15
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