testing/etcd: $ETCD_DATA_DIR and $ETCD_OPTS are ignored
The init file explicitly specify --config-file=$ETCD_CONFIG
which means etcd would ignore all command flags such as --data-dir
and ETCD_OPTS
You could verify that easily by running:
$ etcd --config-file=/etc/etcd/conf.yml --data-dir=/var/lib/this_is_the_datadir
{"level":"info","ts":"2020-07-22T12:03:01.597Z","caller":"etcdmain/config.go:306","msg":"loaded server configuration, other configuration command line flags and environment variables will be ignored if provided","path":"/etc/etcd/conf.yml"}
{"level":"warn","ts":"2020-07-22T12:03:01.597Z","caller":"etcdmain/etcd.go:119","msg":"'data-dir' was empty; using default","data-dir":"kmaster.etcd"}
the output above shows that our --data-dir
flag is ignored and etcd would look up that config in /etc/etcd/conf.yml
instead.
In fact, the official documentation clearly explains this:
Options set on the command line take precedence over those from the environment. If a configuration file is provided, other command line flags and environment variables will be ignored. For example, etcd --config-file etcd.conf.yml.sample --data-dir /tmp will ignore the --data-dir flag.
Ref: https://etcd.io/docs/v3.4.0/op-guide/configuration/
cc @fcolista
Edited by Trung Lê