From 2bde953576f8a76a557d5591303f8045841cfecb Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Mon, 11 Sep 2023 19:20:12 -0700 Subject: [PATCH] chain activation: avoid misfiring (#601) * chain activation: avoid misfiring when activate job gets a successful RPC response for the first time, it should not repeat the query; instead, just parse the output again and check whether the level is zero. This way, if the second rpc query fails, it will just restart the job instead of passing silently, resulting in a non-activated chain stuck at level 0, as happened on Mondaynet today. * fix helm tests --- charts/tezos/scripts/chain-initiator.sh | 17 +++++++++-------- test/charts/private-chain.expect.yaml | 17 +++++++++-------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/charts/tezos/scripts/chain-initiator.sh b/charts/tezos/scripts/chain-initiator.sh index 5f9a2b2e8..0ef545f65 100644 --- a/charts/tezos/scripts/chain-initiator.sh +++ b/charts/tezos/scripts/chain-initiator.sh @@ -1,12 +1,13 @@ set -e CLIENT="/usr/local/bin/octez-client --endpoint http://tezos-node-rpc:8732" -until $CLIENT rpc get /chains/main/blocks/head/header | grep '"level":'; do +OUTPUT="" +until OUTPUT=$($CLIENT rpc get /chains/main/blocks/head/header) && echo "$OUTPUT" | grep '"level":'; do sleep 2 done set -o pipefail -if ! $CLIENT rpc get /chains/main/blocks/head/header | grep '"level": 0,'; then +if ! echo "$OUTPUT" | grep '"level": 0,'; then echo "Chain already activated, considering activation successful and exiting" exit 0 fi @@ -88,9 +89,9 @@ else echo "No 'fromfile#' detected in '$PARAMETERS_FILE', no changes made." fi echo Activating chain: -$CLIENT -d /var/tezos/client --block \ - genesis activate protocol \ - {{ .Values.activation.protocol_hash }} \ - with fitness 1 and key \ - $( cat /etc/tezos/activation_account_name ) \ - and parameters $PARAMETERS_FILE 2>&1 | head -200 +$CLIENT -d /var/tezos/client --block \ + genesis activate protocol \ + {{ .Values.activation.protocol_hash }} \ + with fitness 1 and key \ + $( cat /etc/tezos/activation_account_name ) \ + and parameters /etc/tezos/parameters.json 2>&1 | head -200 diff --git a/test/charts/private-chain.expect.yaml b/test/charts/private-chain.expect.yaml index 576bb6c07..71d3b7b3f 100644 --- a/test/charts/private-chain.expect.yaml +++ b/test/charts/private-chain.expect.yaml @@ -1622,24 +1622,25 @@ spec: - | CLIENT="/usr/local/bin/octez-client --endpoint http://tezos-node-rpc:8732" - until $CLIENT rpc get /chains/main/blocks/head/header | grep '"level":'; do + OUTPUT="" + until OUTPUT=$($CLIENT rpc get /chains/main/blocks/head/header) && echo "$OUTPUT" | grep '"level":'; do sleep 2 done set -x set -o pipefail - if ! $CLIENT rpc get /chains/main/blocks/head/header | grep '"level": 0,'; then + if ! echo "$OUTPUT" | grep '"level": 0,'; then echo "Chain already activated, considering activation successful and exiting" exit 0 fi echo Activating chain: - $CLIENT -d /var/tezos/client --block \ - genesis activate protocol \ - PtJakart2xVj7pYXJBXrqHgd82rdkLey5ZeeGwDgPp9rhQUbSqY \ - with fitness 1 and key \ - $( cat /etc/tezos/activation_account_name ) \ - and parameters /etc/tezos/parameters.json 2>&1 | head -200 + $CLIENT -d /var/tezos/client --block \ + genesis activate protocol \ + PtJakart2xVj7pYXJBXrqHgd82rdkLey5ZeeGwDgPp9rhQUbSqY \ + with fitness 1 and key \ + $( cat /etc/tezos/activation_account_name ) \ + and parameters /etc/tezos/parameters.json 2>&1 | head -200 envFrom: env: