etcd-io / etcd

Distributed reliable key-value store for the most critical data of a distributed system
https://etcd.io
Apache License 2.0
47.5k stars 9.74k forks source link

Only listens on IP of server if you put variables in service file #18522

Closed mattyb-dev closed 3 weeks ago

mattyb-dev commented 3 weeks ago

Bug report criteria

What happened?

The etcd daemon only listens on IP:2379 and/or IP:2380 when the advertise-client-urls, initial-advertise-peer-urls, listn-client-urls and listen-peer-urls variables are on the ExecStart line in the service file. Tried using ETCD_FORMAT and yaml format in the conf file

What did you expect to happen?

That the variables listed above would listen on the IP of the server instead of 127.0.0.1 if defined in the conf file

How can we reproduce it (as minimally and precisely as possible)?

RedHat 8 etcd 3.5.15 Try setting advertise-client-urls, initial-advertise-peer-urls, listen-client-urls and listen-peer-urls variables in the conf file. Then do netstat-an | egrep "2379|2380" and you'll see the ports are only for 127.0.0.1

Anything else we need to know?

SELINUX=permissive firewall-cmd used to open all ports used by etc.

Etcd version (please run commands below)

```console $ etcd --version # paste output here etcd Version: 3.5.15 Git SHA: 9a5533382 Go Version: go1.21.12 Go OS/Arch: linux/amd64 $ etcdctl version # paste output here ``` etcdctl version: 3.5.15 API version: 3.5

Etcd configuration (command line flags or environment variables)

# paste your configuration here Using systemctl start etcd service No env variables set all variables listed above in etcd.service file [Unit] Description=Etcd Server for %i After=network.target After=network-online.target Wants=network-online.target [Service] Type=notify WorkingDirectory=/var/lib/etcd/ #EnvironmentFile=-/etc/etcd/etcd-%i.conf.yml User=etcd # set GOMAXPROCS to number of processors ExecStart=/bin/bash -c "GOMAXPROCS=$(nproc) /usr/bin/etcd --name="special_name_1" --data-dir="/var/lib/etcd/special_name.etcd" --advertise-client-urls="http://10.125.77.181:2379/" --initial-advertise-peer-urls="http://10.125.77.181:2380/" --listen-client-urls="http://10.125.77.181:2379/" --listen-peer-urls="http://10.125.77.181:2380/"" Restart=on-failure LimitNOFILE=65536 [Install] WantedBy=multi-user.target

Etcd debug information (please run commands below, feel free to obfuscate the IP address or FQDN in the output)

Using conf file : [root@fr0-viaasm-0130 etcd]# etcdctl member list -w table +------------------+---------+---------+-----------------------+-----------------------+------------+ |        ID        | STATUS  |  NAME   |      PEER ADDRS       |     CLIENT ADDRS      | IS LEARNER | +------------------+---------+---------+-----------------------+-----------------------+------------+ | 8e9e05c52164694d | started | default | http://localhost:2380/ | http://localhost:2379/ |      false | +------------------+---------+---------+-----------------------+-----------------------+------------+ Using service file with variables : [root@fr0-viaasm-0130 etcd]# etcdctl --endpoints=http://10.125.77.181:2380/ endpoint status -w table +---------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+ | ENDPOINT | ID | VERSION | DB SIZE | IS LEADER | IS LEARNER | RAFT TERM | RAFT INDEX | RAFT APPLIED INDEX | ERRORS | +---------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+ | http://10.125.77.181:2380/ | d4dba89fb1f01b4d | 3.5.15 | 20 kB | true | false | 3 | 6 | 6 | | +---------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+ Using service file with variables :

Relevant log output

Daemon starts correctly, listening on 127.0.0.1 instead of IP addr of server when variables in conf file
mattyb-dev commented 3 weeks ago

[root@mymachine etcd]# etcdctl --endpoints=http://10.125.77.181:2380/ member list -w table +------------------+---------+---------------------+---------------------------+---------------------------+------------+ |        ID        | STATUS  |        NAME         |        PEER ADDRS         |       CLIENT ADDRS        | IS LEARNER | +------------------+---------+---------------------+---------------------------+---------------------------+------------+ | d4dba89fb1f01b4d | started | specialname_1 | http://10.125.77.181:2380/ | http://10.125.77.181:2379/ |      false | +------------------+---------+---------------------+---------------------------+---------------------------+------------+

mattyb-dev commented 3 weeks ago

Used old format of conf file, with ETCD_VARIABLE (not as per https://github.com/etcd-io/etcd/blob/main/etcd.conf.yml.sample) and it worked. So instructions VERY unclear about the format of the config file in 3.5