app-admin/etcd-wrapper: remove ETCD_NAME

`etcd` node's name was defined by `ETCD_NAME`, from `etcd/v3` the server
can't be started with both `ETCD_NAME` and `--name` supplied.

Which leads to three cases:
* `etcd-member.service` starts without further configuration, no issue
since only `ETCD_NAME=%m` is used
* `etcd-member.service` is overrided with a CLC without `name: ` key, no
issue since only `ETCD_NAME=%m` is used
* `etcd-member.service` is overrided with a CLC with a `name: ` key,
there is an issue since in the final service we will have both
`ETCD_NAME=%m` and `--name name-from-clc`

This patch conditionally unset the `ETCD_NAME` in case `--name` is
supplied.

Signed-off-by: Mathieu Tortuyaux <mtortuyaux@microsoft.com>
This commit is contained in:
Mathieu Tortuyaux 2021-11-24 10:48:40 +01:00
parent 8ec91fc7c8
commit ac99563d5e

View File

@ -4,6 +4,17 @@
# ExecStart here. # ExecStart here.
set -e set -e
# Since etcd/v3 we can't use both `--name` and `ETCD_NAME` at the same time.
# We parse the etcd command line options to find a `--name/-name` flag if we found one,
# we unset the `ETCD_NAME` to not conflict with it.
for f in "${@}"; do
if [[ $f =~ ^-?-name=? ]]; then
unset ETCD_NAME
break
fi
done
# Do not pass ETCD_DATA_DIR through to the container. The default path, # Do not pass ETCD_DATA_DIR through to the container. The default path,
# /var/lib/etcd is always used inside the container. # /var/lib/etcd is always used inside the container.
etcd_data_dir="${ETCD_DATA_DIR}" etcd_data_dir="${ETCD_DATA_DIR}"