[bitnami/etcd] Only recalculate the initial cluster config if not provided (#30058)

Only recalculate the initial cluster config if not provided

Signed-off-by: Brad Klein <bklein@cray.com>
Co-authored-by: Brad Klein <bklein@cray.com>
This commit is contained in:
Brad Klein
2023-04-19 10:42:05 +02:00
committed by GitHub
co-authored by Brad Klein
parent fc7da95c0d
commit 3234e29768
3 changed files with 54 additions and 12 deletions
@@ -617,9 +617,17 @@ etcd_initialize() {
info "Restoring snapshot before initializing etcd cluster"
local -a restore_args=("--data-dir" "$ETCD_DATA_DIR")
if [[ ${#initial_members[@]} -gt 1 ]]; then
ETCD_INITIAL_CLUSTER="$(recalculate_initial_cluster)"
export ETCD_INITIAL_CLUSTER
#
# Only recalculate the initial cluster config if it hasn't
# been provided.
#
if is_empty_value "$ETCD_INITIAL_CLUSTER"; then
ETCD_INITIAL_CLUSTER="$(recalculate_initial_cluster)"
export ETCD_INITIAL_CLUSTER
fi
[[ -f "$ETCD_CONF_FILE" ]] && etcd_conf_write "initial-cluster" "$ETCD_INITIAL_CLUSTER"
restore_args+=(
"--name" "$ETCD_NAME"
"--initial-cluster" "$ETCD_INITIAL_CLUSTER"
@@ -665,8 +673,14 @@ etcd_initialize() {
if [[ "${latest_snapshot_file}" != "" ]]; then
info "Restoring etcd cluster from snapshot"
rm -rf "$ETCD_DATA_DIR"
ETCD_INITIAL_CLUSTER="$(recalculate_initial_cluster)"
export ETCD_INITIAL_CLUSTER
#
# Only recalculate the initial cluster config if it hasn't
# been provided.
#
if is_empty_value "$ETCD_INITIAL_CLUSTER"; then
ETCD_INITIAL_CLUSTER="$(recalculate_initial_cluster)"
export ETCD_INITIAL_CLUSTER
fi
[[ -f "$ETCD_CONF_FILE" ]] && etcd_conf_write "initial-cluster" "$ETCD_INITIAL_CLUSTER"
debug_execute etcdctl snapshot restore "${latest_snapshot_file}" \
--name "$ETCD_NAME" \
@@ -617,9 +617,17 @@ etcd_initialize() {
info "Restoring snapshot before initializing etcd cluster"
local -a restore_args=("--data-dir" "$ETCD_DATA_DIR")
if [[ ${#initial_members[@]} -gt 1 ]]; then
ETCD_INITIAL_CLUSTER="$(recalculate_initial_cluster)"
export ETCD_INITIAL_CLUSTER
#
# Only recalculate the initial cluster config if it hasn't
# been provided.
#
if is_empty_value "$ETCD_INITIAL_CLUSTER"; then
ETCD_INITIAL_CLUSTER="$(recalculate_initial_cluster)"
export ETCD_INITIAL_CLUSTER
fi
[[ -f "$ETCD_CONF_FILE" ]] && etcd_conf_write "initial-cluster" "$ETCD_INITIAL_CLUSTER"
restore_args+=(
"--name" "$ETCD_NAME"
"--initial-cluster" "$ETCD_INITIAL_CLUSTER"
@@ -665,8 +673,14 @@ etcd_initialize() {
if [[ "${latest_snapshot_file}" != "" ]]; then
info "Restoring etcd cluster from snapshot"
rm -rf "$ETCD_DATA_DIR"
ETCD_INITIAL_CLUSTER="$(recalculate_initial_cluster)"
export ETCD_INITIAL_CLUSTER
#
# Only recalculate the initial cluster config if it hasn't
# been provided.
#
if is_empty_value "$ETCD_INITIAL_CLUSTER"; then
ETCD_INITIAL_CLUSTER="$(recalculate_initial_cluster)"
export ETCD_INITIAL_CLUSTER
fi
[[ -f "$ETCD_CONF_FILE" ]] && etcd_conf_write "initial-cluster" "$ETCD_INITIAL_CLUSTER"
debug_execute etcdctl snapshot restore "${latest_snapshot_file}" \
--name "$ETCD_NAME" \
@@ -617,9 +617,17 @@ etcd_initialize() {
info "Restoring snapshot before initializing etcd cluster"
local -a restore_args=("--data-dir" "$ETCD_DATA_DIR")
if [[ ${#initial_members[@]} -gt 1 ]]; then
ETCD_INITIAL_CLUSTER="$(recalculate_initial_cluster)"
export ETCD_INITIAL_CLUSTER
#
# Only recalculate the initial cluster config if it hasn't
# been provided.
#
if is_empty_value "$ETCD_INITIAL_CLUSTER"; then
ETCD_INITIAL_CLUSTER="$(recalculate_initial_cluster)"
export ETCD_INITIAL_CLUSTER
fi
[[ -f "$ETCD_CONF_FILE" ]] && etcd_conf_write "initial-cluster" "$ETCD_INITIAL_CLUSTER"
restore_args+=(
"--name" "$ETCD_NAME"
"--initial-cluster" "$ETCD_INITIAL_CLUSTER"
@@ -665,8 +673,14 @@ etcd_initialize() {
if [[ "${latest_snapshot_file}" != "" ]]; then
info "Restoring etcd cluster from snapshot"
rm -rf "$ETCD_DATA_DIR"
ETCD_INITIAL_CLUSTER="$(recalculate_initial_cluster)"
export ETCD_INITIAL_CLUSTER
#
# Only recalculate the initial cluster config if it hasn't
# been provided.
#
if is_empty_value "$ETCD_INITIAL_CLUSTER"; then
ETCD_INITIAL_CLUSTER="$(recalculate_initial_cluster)"
export ETCD_INITIAL_CLUSTER
fi
[[ -f "$ETCD_CONF_FILE" ]] && etcd_conf_write "initial-cluster" "$ETCD_INITIAL_CLUSTER"
debug_execute etcdctl snapshot restore "${latest_snapshot_file}" \
--name "$ETCD_NAME" \