From b70790050db148bc74a45eef6cc21842068e074f Mon Sep 17 00:00:00 2001 From: francois branciard Date: Wed, 5 Aug 2020 01:20:36 +0200 Subject: [PATCH] #237 fix bugs after E2E testing --- deployer/archipel/start-orchestrator.sh | 30 +++++++++++++++++++------ orchestrator/src/heartbeats.js | 2 +- orchestrator/src/orchestrator.js | 2 ++ orchestrator/src/polkadot.js | 7 +++++- 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/deployer/archipel/start-orchestrator.sh b/deployer/archipel/start-orchestrator.sh index 26f7295..e18f923 100755 --- a/deployer/archipel/start-orchestrator.sh +++ b/deployer/archipel/start-orchestrator.sh @@ -54,7 +54,7 @@ if [ ! -z "$CONFIG_FILE" ]; then #set variables from config file #get NODES_ROLE if [ -z "$NODES_ROLE" ]; then - NODES_ROLE=$(cat /config/config.json | jq ".nodesRole") + NODES_ROLE=$(cat /config/config.json | jq ".nodesRole" | sed 's/\"//g') check_cmd $? 'retrieve NODES_ROLE' if [ "$NODES_ROLE" == "null" ]; then echo "Assure old config support. Force config NODES_ROLE to 'operator,operator,operator'" @@ -65,9 +65,25 @@ if [ ! -z "$CONFIG_FILE" ]; then NODE_ROLE=${rolesArray[index]} fi + if [ -z "$NODE_GROUP" ]; then + NODES_GROUP=$(cat /config/config.json | jq ".nodesGroup" | sed 's/\"//g') + check_cmd $? 'retrieve NODES_GROUP' + IFS=',' read -ra groupsArray <<< "$NODES_GROUP" + index=$(( $NODE_ID - 1 )) + NODE_GROUP=${groupsArray[index]} + fi + + if [ -z "$NODE_GROUP_ID" ]; then + NODES_GROUP_ID=$(cat /config/config.json | jq ".nodesGroupId" | sed 's/\"//g') + check_cmd $? 'retrieve NODES_GROUP_ID' + IFS=',' read -ra groupIdsArray <<< "$NODES_GROUP_ID" + index=$(( $NODE_ID - 1 )) + NODE_GROUP_ID=${groupIdsArray[index]} + fi + #get nexmoApiKey if [ -z "$NEXMO_API_KEY" ]; then - NEXMO_API_KEY_LIST=$(cat /config/config.json | jq ".nexmoApiKey") + NEXMO_API_KEY_LIST=$(cat /config/config.json | jq ".nexmoApiKey" | sed 's/\"//g') check_cmd $? 'retrieve NEXMO_API_KEY_LIST' if [ "$NEXMO_API_KEY_LIST" != "null" ]; then IFS=',' read -ra apikeysArray <<< "$NEXMO_API_KEY_LIST" @@ -81,7 +97,7 @@ if [ ! -z "$CONFIG_FILE" ]; then #get nexmoApiSecret if [ -z "$NEXMO_API_SECRET" ]; then - NEXMO_API_SECRET_LIST=$(cat /config/config.json | jq ".nexmoApiSecret") + NEXMO_API_SECRET_LIST=$(cat /config/config.json | jq ".nexmoApiSecret" | sed 's/\"//g') check_cmd $? 'retrieve NEXMO_API_SECRET_LIST' if [ "$NEXMO_API_SECRET_LIST" != "null" ]; then IFS=',' read -ra apiSecretArray <<< "$NEXMO_API_SECRET_LIST" @@ -95,7 +111,7 @@ if [ ! -z "$CONFIG_FILE" ]; then #get nexmoSignatureMethod if [ -z "$NEXMO_API_SIGNATURE_METHOD" ]; then - NEXMO_API_SIGNATURE_METHOD_LIST=$(cat /config/config.json | jq ".nexmoApiSignatureMethod") + NEXMO_API_SIGNATURE_METHOD_LIST=$(cat /config/config.json | jq ".nexmoApiSignatureMethod" | sed 's/\"//g') check_cmd $? 'retrieve NEXMO_API_SIGNATURE_METHOD_LIST' if [ "$NEXMO_API_SIGNATURE_METHOD_LIST" != "null" ]; then IFS=',' read -ra signatureMethodsArray <<< "$NEXMO_API_SIGNATURE_METHOD_LIST" @@ -109,7 +125,7 @@ if [ ! -z "$CONFIG_FILE" ]; then #get nexmoSignatureSecret if [ -z "$NEXMO_API_SIGNATURE_SECRET" ]; then - NEXMO_API_SIGNATURE_SECRET_LIST=$(cat /config/config.json | jq ".nexmoApiSignatureSecret") + NEXMO_API_SIGNATURE_SECRET_LIST=$(cat /config/config.json | jq ".nexmoApiSignatureSecret" | sed 's/\"//g') check_cmd $? 'retrieve NEXMO_API_SIGNATURE_SECRET_LIST' if [ "$NEXMO_API_SIGNATURE_SECRET_LIST" != "null" ]; then IFS=',' read -ra signatureSecretsArray <<< "$NEXMO_API_SIGNATURE_SECRET_LIST" @@ -123,7 +139,7 @@ if [ ! -z "$CONFIG_FILE" ]; then #get NexmoPhoneNumber if [ -z "$NEXMO_PHONE_NUMBER" ]; then - NEXMO_PHONE_NUMBER_LIST=$(cat /config/config.json | jq ".nexmoPhoneNumber") + NEXMO_PHONE_NUMBER_LIST=$(cat /config/config.json | jq ".nexmoPhoneNumber" | sed 's/\"//g') check_cmd $? 'retrieve NEXMO_PHONE_NUMBER_LIST' if [ "$NEXMO_PHONE_NUMBER_LIST" != "null" ]; then IFS=',' read -ra phoneNumbersArray <<< "$NEXMO_PHONE_NUMBER_LIST" @@ -136,7 +152,7 @@ if [ ! -z "$CONFIG_FILE" ]; then fi if [ -z "$OUTLET_PHONE_NUMBER_LIST" ]; then - OUTLET_PHONE_NUMBER_LIST=$(cat /config/config.json | jq ".outletPhoneNumber") + OUTLET_PHONE_NUMBER_LIST=$(cat /config/config.json | jq ".outletPhoneNumber" | sed 's/\"//g') check_cmd $? 'retrieve OUTLET_PHONE_NUMBERS' if [ "$OUTLET_PHONE_NUMBERS" != "null" ]; then OUTLET_PHONE_NUMBER_LIST=$OUTLET_PHONE_NUMBER_LIST diff --git a/orchestrator/src/heartbeats.js b/orchestrator/src/heartbeats.js index 9b9c7ae..18175b5 100644 --- a/orchestrator/src/heartbeats.js +++ b/orchestrator/src/heartbeats.js @@ -33,7 +33,7 @@ class Heartbeats { debug('anyOneAlive', `excludeNode ${excludeNode} aliveTime ${aliveTime} group ${group} bestNumber ${bestNumber}.`); for (const [key, value] of this.heartbeats.entries()) { if (key !== excludeNode) { - debug('anyOneAlive', `${key} is alive.`); + debug('anyOneAlive', `heartbeat found. key:${key}, group:${value.group}, blockNumber:${value.blockNumber}.`); if (value.group === group) { const lastSeenAgo = bestNumber - value.blockNumber; if (lastSeenAgo < aliveTime) { diff --git a/orchestrator/src/orchestrator.js b/orchestrator/src/orchestrator.js index 378477c..6010d71 100644 --- a/orchestrator/src/orchestrator.js +++ b/orchestrator/src/orchestrator.js @@ -443,6 +443,8 @@ class Orchestrator { // Get current leader from chain let currentLeader = await this.chain.getLeader(this.group); const isLeadedGroup = await this.chain.isLeadedGroup(this.group); + + debug('orchestrateService', `Is Group ${this.group} a Leaded Group ? => ${isLeadedGroup} `); currentLeader = currentLeader.toString(); // If current leader is empty diff --git a/orchestrator/src/polkadot.js b/orchestrator/src/polkadot.js index 05887fb..330dbb3 100644 --- a/orchestrator/src/polkadot.js +++ b/orchestrator/src/polkadot.js @@ -466,7 +466,12 @@ class Polkadot { // Launch service in specific mode let containerName = ''; if (mode === 'active') { - const validatorCmdsList = ['--name', `${config.polkadotName.slice(0, -2)}-active`, ...this.commonPolkadotOptions, '--validator', '--reserved-only']; + let name = config.polkadotName; + if (!isEmptyString(config.polkadotAdditionalOptions) && config.polkadotAdditionalOptions.includes('kusama')) { + // slice for never change name for 1000 validator program check + name = config.polkadotName.slice(0, -2); + } + const validatorCmdsList = ['--name', `${name}-active`, ...this.commonPolkadotOptions, '--validator', '--reserved-only']; if (!isEmptyString(config.polkadotReservedNodes)) { const sentryPeers = await this.extractPeers(config.polkadotReservedNodes, config.nodesRole, 'sentry'); validatorCmdsList.push(...formatOptionList('--sentry-nodes', sentryPeers));