From f1b0b3e8b450ed920e35dc523c11d58dc1d9a761 Mon Sep 17 00:00:00 2001 From: asmodat Date: Wed, 7 Apr 2021 10:08:04 +0000 Subject: [PATCH] Gracefull halting & removed pruning see https://github.com/cosmos/cosmos-sdk/issues/6370 for details --- docker/kira/container/sentry/start.sh | 2 +- docker/kira/container/snapshot/start.sh | 4 ++-- docker/kira/container/validator/start.sh | 2 +- workstation/kira/kira-networking.sh | 9 ++++++++- workstation/scripts/await-seed-init.sh | 4 ++++ workstation/scripts/await-sentry-init.sh | 12 ++++++++++-- 6 files changed, 26 insertions(+), 7 deletions(-) diff --git a/docker/kira/container/sentry/start.sh b/docker/kira/container/sentry/start.sh index 89e8e4c0c..acab078eb 100644 --- a/docker/kira/container/sentry/start.sh +++ b/docker/kira/container/sentry/start.sh @@ -107,4 +107,4 @@ $SELF_CONTAINER/configure.sh set +e && source "/etc/profile" &>/dev/null && set -e touch $EXECUTED_CHECK -sekaid start --home=$SEKAID_HOME --grpc.address="$GRPC_ADDRESS" --trace --pruning=everything +sekaid start --home=$SEKAID_HOME --grpc.address="$GRPC_ADDRESS" --trace diff --git a/docker/kira/container/snapshot/start.sh b/docker/kira/container/snapshot/start.sh index 6df4ced6c..3132efd93 100644 --- a/docker/kira/container/snapshot/start.sh +++ b/docker/kira/container/snapshot/start.sh @@ -133,7 +133,7 @@ while :; do sleep 10 kill -2 "$PID1" || echo "INFO: Failed to kill sekai PID $PID1" rm -fv $CFG # invalidate all possible connections - sekaid start --home="$SEKAID_HOME" --grpc.address="$GRPC_ADDRESS" --trace --pruning=everything &>./output2.log &# launch sekai in state observer mode + sekaid start --home="$SEKAID_HOME" --grpc.address="$GRPC_ADDRESS" --trace &>./output2.log &# launch sekai in state observer mode PID1=$! sleep 10 FINISHED_RUNNING="true" @@ -165,7 +165,7 @@ while :; do echo "INFO: Cloning genesis and strarting block sync..." cp -f -v -a "$COMMON_CFG" "$CFG" # recover config from common folder cp -a -v -f "$COMMON_GENESIS" "$LOCAL_GENESIS" # recover genesis from common folder - sekaid start --home="$SEKAID_HOME" --grpc.address="$GRPC_ADDRESS" --halt-height="$HALT_HEIGHT" --trace --pruning=everything &>./output.log || echo "halted" & + sekaid start --home="$SEKAID_HOME" --grpc.address="$GRPC_ADDRESS" --halt-height="$HALT_HEIGHT" --trace &>./output.log || echo "halted" & PID1="$!" sleep 10 i=0 diff --git a/docker/kira/container/validator/start.sh b/docker/kira/container/validator/start.sh index d2e7854ed..6f3f7700a 100644 --- a/docker/kira/container/validator/start.sh +++ b/docker/kira/container/validator/start.sh @@ -134,4 +134,4 @@ $SELF_CONTAINER/configure.sh set +e && source "/etc/profile" &>/dev/null && set -e echoInfo "INFO: Starting validator..." -sekaid start --home=$SEKAID_HOME --trace --pruning=everything +sekaid start --home=$SEKAID_HOME --trace diff --git a/workstation/kira/kira-networking.sh b/workstation/kira/kira-networking.sh index bccc21094..3f14999d3 100644 --- a/workstation/kira/kira-networking.sh +++ b/workstation/kira/kira-networking.sh @@ -118,15 +118,22 @@ echo -e "\e[37;1m--------------------------------------------------" echoInfo "INFO: Starting $TYPE editor..." $KIRA_MANAGER/kira/seeds-edit.sh "$FILE" "$EXPOSURE $TARGET" + COMMON_PATH="$DOCKER_COMMON/$DOCKER_COMMON" + EXIT_FILE="$COMMON_PATH/exit" + HALT_FILE="$COMMON_PATH/halt" + echoInfo "INFO: Copying $TYPE configuration to the $CONTAINER container common directory..." - cp -a -v -f "$FILE" "$DOCKER_COMMON/$CONTAINER/$TYPE" + cp -a -v -f "$FILE" "$COMMON_PATH/$TYPE" echoInfo "INFO: To apply changes you will have to restart your $EXPOSURE facing $CONTAINER container" SELECT="." && while ! [[ "${SELECT,,}" =~ ^(r|c)$ ]] ; do echoNErr "Choose to [R]estart $CONTAINER container or [C]ontinue: " && read -d'' -s -n1 SELECT && echo ""; done [ "${SELECT,,}" == "c" ] && continue echoInfo "INFO: Re-starting $CONTAINER container..." + touch "$EXIT_FILE" + cntr=0 && while [ -f "$EXIT_FILE" ] && [ $cntr -lt 20 ] ; do echoInfo "INFO: Waiting for container '$CONTAINER' to halt ($cntr/20) ..." && cntr=$(($cntr + 1)) && sleep 5 ; done $KIRA_SCRIPTS/container-restart.sh $CONTAINER + rm -fv "$HALT_FILE" "$EXIT_FILE" elif [ "${OPTION,,}" == "f" ]; then echoInfo "INFO: Reinitalizing firewall..." $KIRA_MANAGER/networking.sh diff --git a/workstation/scripts/await-seed-init.sh b/workstation/scripts/await-seed-init.sh index a9653c654..4fcc5144b 100644 --- a/workstation/scripts/await-seed-init.sh +++ b/workstation/scripts/await-seed-init.sh @@ -8,6 +8,7 @@ SEED_NODE_ID=$2 COMMON_PATH="$DOCKER_COMMON/$CONTAINER_NAME" COMMON_LOGS="$COMMON_PATH/logs" HALT_FILE="$COMMON_PATH/halt" +EXIT_FILE="$COMMON_PATH/exit" while : ; do PREVIOUS_HEIGHT=0 @@ -108,7 +109,10 @@ while : ; do set -x if [ "${ACCEPT,,}" == "r" ] ; then echoWarn "WARINIG: Container sync operation will be attempted again, please wait..." && sleep 5 + touch "$EXIT_FILE" + cntr=0 && while [ -f "$EXIT_FILE" ] && [ $cntr -lt 20 ] ; do echoInfo "INFO: Waiting for container '$CONTAINER_NAME' to halt ($cntr/20) ..." && cntr=$(($cntr + 1)) && sleep 5 ; done $KIRA_SCRIPTS/container-restart.sh "$CONTAINER_NAME" + rm -fv "$HALT_FILE" "$EXIT_FILE" sleep 5 continue else diff --git a/workstation/scripts/await-sentry-init.sh b/workstation/scripts/await-sentry-init.sh index 857989da4..ea8041e63 100644 --- a/workstation/scripts/await-sentry-init.sh +++ b/workstation/scripts/await-sentry-init.sh @@ -9,6 +9,8 @@ SAVE_SNAPSHOT=$3 [ -z "$SAVE_SNAPSHOT" ] && SAVE_SNAPSHOT="false" COMMON_PATH="$DOCKER_COMMON/$CONTAINER_NAME" COMMON_LOGS="$COMMON_PATH/logs" +HALT_FILE="$COMMON_PATH/halt" +EXIT_FILE="$COMMON_PATH/exit" while : ; do PREVIOUS_HEIGHT=0 @@ -109,7 +111,10 @@ while : ; do set -x if [ "${ACCEPT,,}" == "r" ] ; then echoWarn "WARINIG: Container sync operation will be attempted again, please wait..." && sleep 5 + touch "$EXIT_FILE" + cntr=0 && while [ -f "$EXIT_FILE" ] && [ $cntr -lt 20 ] ; do echoInfo "INFO: Waiting for container '$CONTAINER_NAME' to halt ($cntr/20) ..." && cntr=$(($cntr + 1)) && sleep 5 ; done $KIRA_SCRIPTS/container-restart.sh "$CONTAINER_NAME" + rm -fv "$HALT_FILE" "$EXIT_FILE" sleep 5 continue else @@ -177,6 +182,7 @@ if [ "${SAVE_SNAPSHOT,,}" == "true" ] ; then cntr=0 && while [ -f "$EXIT_FILE" ] && [ $cntr -lt 10 ] ; do echoInfo "INFO: Waiting for container '$CONTAINER_NAME' to halt ($cntr/10) ..." && cntr=$(($cntr + 1)) && sleep 15 ; done echoInfo "INFO: Re-starting $CONTAINER_NAME container..." $KIRA_SCRIPTS/container-restart.sh $CONTAINER_NAME + rm -fv "$HALT_FILE" "$EXIT_FILE" echoInfo "INFO: Creating new snapshot..." @@ -196,9 +202,11 @@ if [ "${SAVE_SNAPSHOT,,}" == "true" ] ; then CDHelper text lineswap --insert="KIRA_SNAP_PATH=\"$DESTINATION_FILE\"" --prefix="KIRA_SNAP_PATH=" --path=$ETC_PROFILE --append-if-found-not=True echo "INFO: Un-Halting $CONTAINER_NAME container" - rm -fv $HALT_FILE - echo "INFO: Re-starting $CONTAINER_NAME container..." + touch $EXIT_FILE + cntr=0 && while [ -f "$EXIT_FILE" ] && [ $cntr -lt 10 ] ; do echoInfo "INFO: Waiting for container '$CONTAINER_NAME' to halt ($cntr/10) ..." && cntr=$(($cntr + 1)) && sleep 15 ; done + echoInfo "INFO: Re-starting $CONTAINER_NAME container..." $KIRA_SCRIPTS/container-restart.sh $CONTAINER_NAME + rm -fv "$HALT_FILE" "$EXIT_FILE" ls -1 "$KIRA_SNAP" [ ! -f "$DESTINATION_FILE" ] && echoErr "ERROR: Failed to create snpashoot, file $DESTINATION_FILE was not found." && exit 1