mirror of
https://github.com/bitnami/containers.git
synced 2026-10-18 22:09:46 +02:00
Init snapshot filename to start etcd clusters from should be a variable (#17)
This commit is contained in:
committed by
GitHub
parent
8d85e5e285
commit
fbb9cee42d
@@ -27,6 +27,7 @@ etcd_env_vars=(
|
||||
ETCD_START_FROM_SNAPSHOT
|
||||
ETCD_DISASTER_RECOVERY
|
||||
ETCD_ON_K8S
|
||||
ETCD_INIT_SNAPSHOT_FILENAME
|
||||
ETCDCTL_API
|
||||
ETCD_NAME
|
||||
ETCD_LOG_LEVEL
|
||||
@@ -78,6 +79,7 @@ export ETCD_CLUSTER_DOMAIN="${ETCD_CLUSTER_DOMAIN:-}"
|
||||
export ETCD_START_FROM_SNAPSHOT="${ETCD_START_FROM_SNAPSHOT:-no}"
|
||||
export ETCD_DISASTER_RECOVERY="${ETCD_DISASTER_RECOVERY:-no}"
|
||||
export ETCD_ON_K8S="${ETCD_ON_K8S:-no}"
|
||||
export ETCD_INIT_SNAPSHOT_FILENAME="${ETCD_INIT_SNAPSHOT_FILENAME:-}"
|
||||
|
||||
# etcd native environment variables (see https://etcd.io/docs/current/op-guide/configuration)
|
||||
export ETCDCTL_API="${ETCDCTL_API:-3}"
|
||||
|
||||
@@ -39,6 +39,9 @@ etcd_validate() {
|
||||
else
|
||||
is_empty_value "$ETCD_ROOT_PASSWORD" && print_validation_error "The ETCD_ROOT_PASSWORD environment variable is empty or not set. Set the environment variable ALLOW_NONE_AUTHENTICATION=yes to allow a blank password. This is only recommended for development environments."
|
||||
fi
|
||||
if is_boolean_yes "$ETCD_START_FROM_SNAPSHOT" && [[ ! -f "/init-snapshot/${ETCD_INIT_SNAPSHOT_FILENAME}" ]]; then
|
||||
print_validation_error "You are trying to initialize etcd from a snapshot, but no snapshot was found. Set the environment variable ETCD_INIT_SNAPSHOT_FILENAME with the snapshot filename and mount it at '/init-snapshot' directory."
|
||||
fi
|
||||
|
||||
[[ "$error_code" -eq 0 ]] || return "$error_code"
|
||||
}
|
||||
@@ -361,7 +364,7 @@ etcd_initialize() {
|
||||
fi
|
||||
fi
|
||||
if is_boolean_yes "$ETCD_START_FROM_SNAPSHOT"; then
|
||||
if [[ -f "/init-snapshot/FOO" ]]; then
|
||||
if [[ -f "/init-snapshot/${ETCD_INIT_SNAPSHOT_FILENAME}" ]]; then
|
||||
info "Restoring snapshot before initializing etcd cluster"
|
||||
local -a restore_args=("--data-dir" "$ETCD_DATA_DIR")
|
||||
if [[ ${#initial_members[@]} -gt 1 ]]; then
|
||||
@@ -374,7 +377,7 @@ etcd_initialize() {
|
||||
"--initial-advertise-peer-urls" "$ETCD_INITIAL_ADVERTISE_PEER_URLS"
|
||||
)
|
||||
fi
|
||||
debug_execute etcdctl snapshot restore "/init-snapshot/FOO" "${restore_args[@]}"
|
||||
debug_execute etcdctl snapshot restore "/init-snapshot/${ETCD_INIT_SNAPSHOT_FILENAME}" "${restore_args[@]}"
|
||||
debug_execute etcd_store_member_id &
|
||||
else
|
||||
error "There was no snapshot to restore!"
|
||||
|
||||
Reference in New Issue
Block a user