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

etcd should use default values for advertised client and peer URLs. #2858

Closed
kelseyhightower opened this issue May 22, 2015 · 12 comments
Closed
Milestone

Comments

@kelseyhightower
Copy link
Contributor

I tried configuring etcd v2.010 with the following settings:

ETCD_NAME=etcd
ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379
ETCD_LISTEN_PEER_URLS=http://0.0.0.0:2380
ETCD_DATA_DIR=/var/lib/etcd
ETCD_INITIAL_CLUSTER_TOKEN=kubernetes

I got the following error:

May 22 13:07:04 localhost systemd[1]: Started etcd.
May 22 13:07:04 localhost systemd[1]: Starting etcd...
May 22 13:07:04 localhost systemd[1]: etcd.service: main process exited, code=exited, status=1/FAILURE
May 22 13:07:04 localhost systemd[1]: Unit etcd.service entered failed state.
May 22 13:07:04 localhost systemd[1]: etcd.service failed.
May 22 13:07:04 localhost etcd[6165]: 2015/05/22 13:07:04 error verifying flags, -advertise-client-urls is required when -listen-client-urls is set explicitly. See 'etcd -help'.
May 22 13:07:04 localhost etcd[6165]: 2015/05/22 13:07:04 When listening on specific address(es), this etcd process must advertise accessible url(s) to each connected client.

How I expect this to work:

I'm currently trying to bootstrap a single node etcd cluster, and don't know the IP address ahead of time. Ideally I want to listen to all interfaces and allow clients such as Kubernetes and etcdctl to interact with etcd.

@kelseyhightower
Copy link
Contributor Author

I think the real problem is the fact that clients call sync cluster which means I really need to use valid IPs for etcd, even for single node clusters.

@xiang90
Copy link
Contributor

xiang90 commented May 22, 2015

@kelseyhightower You have to know the valid IPs. For the most common use case (multi member setup), each member needs to publish its own clientURLs to the cluster. So clients can find other members through one member. If we allow unknown clientURLs, it will introduce issues like the one you mentioned.

@kelseyhightower
Copy link
Contributor Author

@xiang90 What about a flag so the user can ask etcd to grab the default IPv4 address like we do in fleet. For example, fleet does the following: https://github.com/coreos/fleet/blob/b298bbefa0f6334344e5ef3ba08f789faf8c02ad/machine/coreos.go#L109

@xiang90
Copy link
Contributor

xiang90 commented May 22, 2015

@kelseyhightower Sure. Let us try that approach for clientURLs.

@yichengq
Copy link
Contributor

The fatal is used to avoid unset advertise-client-urls when bootstrap. This can be bypassed by setting -advertise-client-urls http://127.0.0.1:2379 explicitly. (As long as user knows this should be set, it is fine.)

Another possible thought to solve the issue is to grab all interface IPs first and run etcd using them by shell scripts, given the fact that this is only used for single node cluster.

@xiang90
Copy link
Contributor

xiang90 commented May 22, 2015

@yichengq I think @kelseyhightower want to make cloud config or something pre-boot works...

@yichengq
Copy link
Contributor

@xiang90 @kelseyhightower If it uses cloudinit, $private_ipv4 and $public_ipv4 could be used to set the flag. I may lack of some context/environment here.

@colebrumley
Copy link

I don't understand why the listening addresses need to be bound to a specific IP. From my perspective, the advertised listening URL needs to be a valid IP so that other cluster members can contact it, but why can't I listen on all interfaces so that my clients can point to either 127.0.0.1 if localhost OR the machine's actual IP? If the advertised URL isn't the one being sent to the cluster, what's the point of having it?

Shouldn't I be able to do:

etcd -data-dir=/data \
  -name=test \
  -listen-peer-urls=http://0.0.0.0:7001,http://0.0.0.0:2380 \
  -listen-client-urls=http://0.0.0.0:4001,http://0.0.0.0:2379 \
  -initial-advertise-peer-urls=http://my_actual_ip:7001 \
  -advertise-client-urls=http://my_actual_ip:4001 \
  -discovery=https://discovery.etcd.io/blah

Doing so gives me an default has different advertised URLs in the cluster and advertised peer URLs list error:

cole@sol:~/docker-etcd$ docker logs etcd1
Using default CLIENT_URLS (http://0.0.0.0:4001,http://0.0.0.0:2379)
Using default PEER_URLS (http://0.0.0.0:7001,http://0.0.0.0:2380)
Using default ADVERTISE_CLIENT_URLS (http://172.17.0.85:4001,http://172.17.0.85:2379)
Using default ADVERTISE_PEER_URLS (http://172.17.0.85:7001,http://172.17.0.85:2380)
Running '/bin/etcd -data-dir=/data -listen-peer-urls=http://0.0.0.0:7001,http://0.0.0.0:2380 -listen-client-urls=http://0.0.0.0:4001,http://0.0.0.0:2379 -initial-advertise-peer-urls=http://172.17.0.85:7001,http://172.17.0.85:2380 -advertise-client-urls=http://172.17.0.85:4001,http://172.17.0.85:2379 '
BEGIN ETCD OUTPUT

2015/06/07 19:20:45 etcd: listening for peers on http://0.0.0.0:2380
2015/06/07 19:20:45 etcd: listening for peers on http://0.0.0.0:7001
2015/06/07 19:20:45 etcd: listening for client requests on http://0.0.0.0:2379
2015/06/07 19:20:45 etcd: listening for client requests on http://0.0.0.0:4001
2015/06/07 19:20:45 etcdserver: datadir is valid for the 2.0.1 format
2015/06/07 19:20:45 etcd: stopping listening for client requests on http://0.0.0.0:4001
2015/06/07 19:20:45 etcd: stopping listening for client requests on http://0.0.0.0:2379
2015/06/07 19:20:45 etcd: stopping listening for peers on http://0.0.0.0:7001
2015/06/07 19:20:45 etcd: stopping listening for peers on http://0.0.0.0:2380
2015/06/07 19:20:45 etcd: default has different advertised URLs in the cluster and advertised peer URLs list

ETCD HAS DIED

@yichengq
Copy link
Contributor

yichengq commented Jun 9, 2015

@colebrumley You definitely can listen on all interfaces.

Thie error indicates that the cluster info fetched from discovery token conflicts with the configuration that you give in the flags. You can check the cluster info in discovery token by opening it in the browser.

One possibility for this error is that you reused discovery token for cluster creation, which is not allowed.

If this is still a problem, feel free to open an issue to discuss.

@wangzhezhe
Copy link

I find the same problem.

And even if I use this flag --initial-cluster-state new it didn't help.

Here is my start command:

/usr/local/bin/etcd  --initial-cluster-state new  \
--initial-advertise-peer-urls 'http://10.10.103.224:7001' \
--listen-peer-urls 'http://10.10.103.224:7001'  \
--listen-client-urls 'http://10.10.103.224:4001' \
--advertise-client-urls 'http://10.10.103.224:4001' \
 --data-dir=/var/etcd/data

And this output:

2015/07/23 08:00:55 etcd: listening for peers on http://10.10.103.224:7001
2015/07/23 08:00:55 etcd: listening for client requests on http://10.10.103.224:4001
2015/07/23 08:00:55 etcdserver: datadir is valid for the 2.0.1 format
2015/07/23 08:00:55 etcd: stopping listening for client requests on http://10.10.103.224:4001
2015/07/23 08:00:55 etcd: stopping listening for peers on http://10.10.103.224:7001
2015/07/23 08:00:55 etcd: default has different advertised URLs in the cluster and advertised peer URLs list

Hope to get some help.

@yichengq

cc @wonderflow

@wangzhezhe
Copy link

How to assign the peer addr automatically ? it seems the error:
default has different advertised URLs in the cluster and advertised peer URLs list
will appear if I use -peer-addr and -peer-bind-addr or initial-advertise-peer-urls and listen-peer-urls

my etcd version is 2.0.9

Hope to get some help ! Thank you !

@xiang90
Copy link
Contributor

xiang90 commented Jul 23, 2015

@wangzhezhe You also need to set initial-cluster correctly. We have improved the log output in the recent release version of etcd too.

@xiang90 xiang90 added the ux label Aug 25, 2015
heyitsanthony pushed a commit to heyitsanthony/etcd that referenced this issue Aug 13, 2016
heyitsanthony pushed a commit to heyitsanthony/etcd that referenced this issue Aug 13, 2016
heyitsanthony pushed a commit to heyitsanthony/etcd that referenced this issue Aug 13, 2016
heyitsanthony pushed a commit to heyitsanthony/etcd that referenced this issue Aug 13, 2016
@xiang90 xiang90 added this to the v3.1.0 milestone Aug 13, 2016
heyitsanthony pushed a commit to heyitsanthony/etcd that referenced this issue Aug 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

6 participants