diff --git a/bitnami/etcd/3/debian-10/rootfs/opt/bitnami/scripts/etcd-env.sh b/bitnami/etcd/3/debian-10/rootfs/opt/bitnami/scripts/etcd-env.sh index be660bdb52b2..7de2af9b368e 100644 --- a/bitnami/etcd/3/debian-10/rootfs/opt/bitnami/scripts/etcd-env.sh +++ b/bitnami/etcd/3/debian-10/rootfs/opt/bitnami/scripts/etcd-env.sh @@ -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}" diff --git a/bitnami/etcd/3/debian-10/rootfs/opt/bitnami/scripts/libetcd.sh b/bitnami/etcd/3/debian-10/rootfs/opt/bitnami/scripts/libetcd.sh index a3acbf3bf1de..71aa93676d21 100644 --- a/bitnami/etcd/3/debian-10/rootfs/opt/bitnami/scripts/libetcd.sh +++ b/bitnami/etcd/3/debian-10/rootfs/opt/bitnami/scripts/libetcd.sh @@ -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!"