gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-grid5k] 85/189: fixes


From: gnunet
Subject: [taler-grid5k] 85/189: fixes
Date: Thu, 28 Apr 2022 10:47:35 +0200

This is an automated email from the git hooks/post-receive script.

marco-boss pushed a commit to branch master
in repository grid5k.

commit 1f6322fd23c9f858370c2ecb7eccd8de1d131932
Author: Boss Marco <bossm8@bfh.ch>
AuthorDate: Thu Mar 17 08:45:10 2022 +0100

    fixes
---
 experiment/scripts/exchange.sh | 29 +++++++++++++----------------
 experiment/scripts/helpers.sh  | 17 +++--------------
 experiment/scripts/monitor.sh  |  6 +++---
 experiment/scripts/run.sh      | 26 +++++++++++++-------------
 experiment/scripts/setup.sh    | 20 +++++++++++++++-----
 5 files changed, 47 insertions(+), 51 deletions(-)

diff --git a/experiment/scripts/exchange.sh b/experiment/scripts/exchange.sh
index 3e1527b..cc70710 100755
--- a/experiment/scripts/exchange.sh
+++ b/experiment/scripts/exchange.sh
@@ -55,7 +55,7 @@ function start_other_exchange_binaries() {
 function setup_primary_exchange() {
 
   # Setup the shared key directory when we use a secondary node
-  if [[ ${NUM_EXCHANGE_HOSTS} != "1" ]]; then
+  if [[ ${NUM_EXCHANGES} != "1" ]]; then
     rm -rf /home/${G5K_USER}/taler || true
     mkdir -p /home/${G5K_USER}/taler/exchange-secmod-{cs,rsa,eddsa}
   fi
@@ -95,20 +95,16 @@ function init_secondary_exchange() {
 }
 
 # Start N new exchange-http daemons
+# $1: N - number of currently running exchanges
 # $1: N - number of new exchanges to start
 function start_exchanges() {
-  # Get all currently running ones so the next free 
-  # port can be calculated: 10000 + RUNNING
-  RUNNING=$(ps -aux | grep "[taler]-exchange-httpd" | wc -l)
-
-  # We cant do seq 0 n, if n=0 it would yield 0, thus do seq n and decrement
-  # by one, then seq 0 yields nothing
-  for i in $(seq ${1}); do
-    # seq starts at 1 - substract it
-    let "i+=${RUNNING}-1" || true
-    let "i+=10000"
-    systemctl restart taler-exchange-httpd@"${i}".socket \
-                      taler-exchange-httpd@"${i}".service
+
+  let "START=$1+10000"
+  let "END=$START+$2"
+
+  for PORT in $(seq $START $END); do
+    systemctl restart taler-exchange-httpd@"${PORT}".socket \
+                      taler-exchange-httpd@"${PORT}".service
     # Wait so they have some small delay in between their routines from the 
start
     sleep 0.05
   done
@@ -123,14 +119,15 @@ function stop_exchanges() {
 case $1 in
   init-primary)
     init_primary_exchange
-    start_exchanges "$((${NUM_EXCHANGE_PROCESSES}-1))"
+    start_exchanges "0" "$((${NUM_EXCHANGE_PROCESSES}-1))"
     ;;
   init-secondary)
     init_secondary_exchange
-    start_exchanges "${NUM_EXCHANGE_PROCESSES}"
+    start_exchanges "0" "${NUM_EXCHANGE_PROCESSES}"
     ;;
   start)
-    start_exchanges $2
+    RUNNING=$(ps -aux | grep "[taler]-exchange-httpd" | wc -l)
+    start_exchanges $RUNNING $2
     ;;
   stop)
     stop_exchanges $2
diff --git a/experiment/scripts/helpers.sh b/experiment/scripts/helpers.sh
index 0f54743..99516f6 100755
--- a/experiment/scripts/helpers.sh
+++ b/experiment/scripts/helpers.sh
@@ -106,11 +106,11 @@ function setup_exchange_config_master_key_from_api() {
 
   setup_exchange_config_without_master_key
 
-  wait_for_keys "${PROXY_DOMAIN}"
+  wait_for_keys "${PRIMARY_EXCHANGE}:10000"
 
   MASTER_KEY=$(
     curl -k -f \
-       "${PROXY_DOMAIN}/keys" \
+       "${PRIMARY_EXCHANGE}:10000/keys" \
        | jq -r '.master_public_key'
   )
 
@@ -141,7 +141,7 @@ function setup_exchange_config_without_master_key() {
          -e "s/<AGGREGATOR_SHARD_SIZE_HERE>/${AGGREGATOR_SHARD_SIZE}/g" \
        /etc/taler/conf.d/exchange-business.conf
 
-  if [[ ${NUM_EXCHANGE_HOSTS} != "1" ]]; then
+  if [[ ${NUM_EXCHANGES} != "1" ]]; then
     # Use a shared NFS key directory when we have multiple exchange-httpd 
servers
     sed -i "s|<SM_KEY_DIR_HERE>|/home/${G5K_USER}/taler|g" \
         /etc/taler/conf.d/exchange-secmod.conf
@@ -219,17 +219,6 @@ function get_exchange_hosts() {
   get_hosts "${EXCHANGE_DOMAIN}"
 }
 
-# Get all exchanges which are registered in the nginx proxy config
-# Returns the whole domain - e.g. exchange.perf.taler:80
-function get_exchanges() {
-  IFS=$'\n' read -r -d '' -a EXCHANGES < <(\
-    ssh -o StrictHostKeyChecking=no ${PROXY_DOMAIN} \
-      grep -E "^[[:space:]]*server[[:space:]]exch" 
/etc/nginx/sites-enabled/proxy \
-      | cut -d ";" -f 1 | cut -d " " -f 4 \
-  )
-  echo ${EXCHANGES[@]}
-}
-
 # Display a help message and exit
 # $1: script name to display help for
 # $2: info message about the script to display
diff --git a/experiment/scripts/monitor.sh b/experiment/scripts/monitor.sh
index baa527b..a6a1467 100755
--- a/experiment/scripts/monitor.sh
+++ b/experiment/scripts/monitor.sh
@@ -125,9 +125,9 @@ function add_shard_nodes_to_prometheus() {
 # Requires no argument, since servers are retrieved from dns
 function add_exchange_nodes_to_prometheus() {
   for EXCH in $(get_exchange_hosts); do
-    if ! grep -q "${EXCHANGE}" /etc/monitor/prometheus.yaml;
+    if ! grep -q "${EXCH}" /etc/monitor/prometheus.yaml;
     then
-      sed -i "/<EXCHANGE_NODES_HERE/a \ \ \ \ \ \ - 
'${EXCHANGE_DOMAIN//\*/${EXCHANGE}}:9100'" \
+      sed -i "/<EXCHANGE_NODES_HERE/a \ \ \ \ \ \ - 
'${EXCHANGE_DOMAIN//\*/${EXCH}}:9100'" \
               /etc/monitor/prometheus.yaml
     fi
   done
@@ -169,7 +169,7 @@ function init_monitor() {
       cat /etc/monitor/node-exporters.yaml.tpl | \
            envsubst >> /etc/monitor/prometheus.yaml
       add_wallet_nodes_to_prometheus
-      add_shards_nodes_to_prometheus
+      add_shard_nodes_to_prometheus
       add_exchange_nodes_to_prometheus
     fi
   fi
diff --git a/experiment/scripts/run.sh b/experiment/scripts/run.sh
index 6c85c1f..e905587 100644
--- a/experiment/scripts/run.sh
+++ b/experiment/scripts/run.sh
@@ -11,81 +11,81 @@ then
 fi
 
 if [[ "${HOSTNAME}" =~ ${BANK_HOSTS} ]]; then 
-    set_host bank
+    set_host ${NODE_NAME}
     set_ddn ${BANK_DOMAIN}
     setup_log
     enable_logrotate
     exec ~/scripts/bank.sh init
 elif [[ "${HOSTNAME}" =~ ${DB_HOSTS} ]]; then 
-    set_host database
+    set_host ${NODE_NAME}
     set_ddn ${DATABASE_DOMAIN}
     setup_log
     enable_logrotate
     exec ~/scripts/database.sh init
 elif [[ "${HOSTNAME}" =~ ${SHARD_HOSTS} ]]; then 
-    set_host shard
+    set_host ${NODE_NAME}
     set_ddn "${SHARD_DOMAIN//\*/${G5K_HOST}}"
     setup_log
     enable_logrotate
     exec ~/scripts/shard.sh init
 elif [[ "${HOSTNAME}" =~ ${EXCHANGE_HOSTS} ]]; then 
-    set_host primary-exchange
+    set_host ${NODE_NAME}
     set_ddn ${EXCHANGE_DOMAIN//\*/${G5K_HOST}}
     setup_log
     enable_logrotate
     enable_netdelay ${DATABASE_DOMAIN}
-    if [[ "${G5K_HOST}" =~ ${PRIMARY_EXCHANGE} ]]; then
+    if [[ "${PRIMARY_EXCHANGE}" =~ "${G5K_HOST}" ]]; then
       exec ~/scripts/exchange.sh init-primary
     else
       exec ~/scripts/exchange.sh init-secondary
     fi
 elif [[ "${HOSTNAME}" =~ ${AGGREGATOR_HOSTS} ]]; then 
-    set_host exchange-aggregator
+    set_host ${NODE_NAME}
     set_ddn ${EXCH_AGGREGATOR_DOMAIN}
     setup_log
     enable_logrotate
     enable_netdelay ${DATABASE_DOMAIN}
     exec ~/scripts/exchange-aggregator.sh init
 elif [[ "${HOSTNAME}" =~ ${CLOSER_HOSTS} ]]; then 
-    set_host exchange-closer
+    set_host ${NODE_NAME}
     set_ddn ${EXCH_CLOSER_DOMAIN}
     setup_log
     enable_logrotate
     enable_netdelay ${DATABASE_DOMAIN}
     exec ~/scripts/exchange-closer.sh init
 elif [[ "${HOSTNAME}" =~ ${TRANSFER_HOSTS} ]]; then 
-    set_host exchange-transfer
+    set_host ${NODE_NAME}
     set_ddn ${EXCH_TRANSFER_DOMAIN}
     setup_log
     enable_logrotate
     enable_netdelay ${DATABASE_DOMAIN}
     exec ~/scripts/exchange-transfer.sh init
 elif [[ "${HOSTNAME}" =~ ${WIREWATCH_HOSTS} ]]; then 
-    set_host exchange-wirewatch
+    set_host ${NODE_NAME}
     set_ddn ${EXCH_WIREWATCH_DOMAIN}
     setup_log
     enable_logrotate
     enable_netdelay ${DATABASE_DOMAIN}
     exec ~/scripts/exchange-wirewatch.sh init
 elif [[ "${HOSTNAME}" =~ ${MERCHANT_HOSTS} ]]; then 
-    set_host merchant
+    set_host ${NODE_NAME}
     set_ddn ${MERCHANT_DOMAIN}
     setup_log
     enable_logrotate
     exec ~/scripts/merchant.sh init
 elif [[ "${HOSTNAME}" =~ ${MONITOR_HOSTS} ]]; then 
-    set_host monitor
+    set_host ${NODE_NAME}
     set_ddn ${MONITOR_DOMAIN}
     exec ~/scripts/monitor.sh init
 elif [[ "${HOSTNAME}" =~ ${PROXY_HOSTS} ]]; then 
-    set_host proxy
+    set_host ${NODE_NAME}
     set_ddn ${PROXY_DOMAIN}
     enable_netdelay ${PRIMARY_EXCHANGE}
     setup_log
     enable_logrotate
     exec ~/scripts/proxy.sh init
 elif [[ "${HOSTNAME}" =~ ${DNS_HOSTS} ]]; then 
-    set_host dns
+    set_host ${NODE_NAME}
     exec ~/scripts/dns.sh
 else
     set_host wallet
diff --git a/experiment/scripts/setup.sh b/experiment/scripts/setup.sh
index ca04ec2..290966b 100644
--- a/experiment/scripts/setup.sh
+++ b/experiment/scripts/setup.sh
@@ -29,11 +29,13 @@ function parse_experiment_nodes() {
   # This will be used in run.sh to determine which role script to execute
   for NODE in ${NODES}; do
     NODES_STR=$(\
-      cat ~/nodes.json | \
-      jq --arg NODE ${NODE}.* -r 'map(select(.node | test($NODE)) | .host) |
-                                  join("|") |
-                                 select(. != "") // "none"'
+      jq --arg NODE ${NODE}.* -r \
+        'map(select(.node | test($NODE)) | .host) |
+         join("|") |
+         select(. != "") // "none"' \
+      ~/nodes.json
     )
+
     if [[ ${NODE} == "Exchange" ]]; then
       # Dynamically define one exchange node as primary (the one which
       # is responsible for key creation)
@@ -42,12 +44,20 @@ function parse_experiment_nodes() {
           awk -F '|' '{print $1}' | \
          cut -d '.' -f 1 \
       )
-      echo "PRIMARY_EXCHANGE=\"${EXCHANGE_DOMAIN//\*${PRIMARY_EXCH}}\"" >> 
~/.env
+      echo "PRIMARY_EXCHANGE=\"${EXCHANGE_DOMAIN//\*/${PRIMARY_EXCH}}\"" >> 
~/.env
     fi
     echo "${NODE^^}_HOSTS=\"${NODES_STR}\"" >> ~/.env
     echo "NUM_${NODE^^}S=$(echo ${NODES_STR} | awk -F '|' '{print NF}')" >> 
~/.env
   done
 
+  # Export NODE_NAME, which can be used to set log directories for example
+  jq -M -r '.[] | .node, .host' ~/nodes.json | \
+  while read -r NODE; read -r HOST; do 
+    if [[ "${HOSTNAME}" == "${HOST}" ]]; then
+      echo "NODE_NAME=\"${NODE,,}\"" >> ~/.env
+    fi
+  done
+
   echo "WALLET_HOSTS=*" >> ~/.env
 
   echo "G5K_HOST=\"$(hostname | cut -d '.' -f1)\"" >> ~/.env

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]