20610: Adds node list & role->nodes map variables.
authorLucas Di Pentima <lucas.dipentima@curii.com>
Wed, 26 Jul 2023 19:57:09 +0000 (16:57 -0300)
committerLucas Di Pentima <lucas.dipentima@curii.com>
Wed, 26 Jul 2023 19:57:09 +0000 (16:57 -0300)
Uses the node list variable to configure prometheus node exporter from the
configuration in local.params.

Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima@curii.com>

tools/salt-install/config_examples/multi_host/aws/pillars/prometheus_server.sls
tools/salt-install/local.params.example.multiple_hosts
tools/salt-install/provision.sh

index bbf997b7be364700372d55b308ad527b7a7a9aae..e64694f4f4c1bd45b8e2155e9fdf6e7f7dca924e 100644 (file)
@@ -59,7 +59,7 @@ prometheus:
             - job_name: keep_balance
               bearer_token: __MANAGEMENT_TOKEN__
               static_configs:
-                - targets: ['__CONTROLLER_INT_IP__:9005']
+                - targets: ['__KEEPBALANCE_INT_IP__:9005']
                   labels:
                     instance: keep-balance.__CLUSTER__
                     cluster: __CLUSTER__
@@ -90,14 +90,14 @@ prometheus:
                     cluster: __CLUSTER__
 
             # Nodes
+            {%- set node_list = "__NODELIST__".split(',') %}
+            {%- set nodes = [] %}
+            {%- for node in node_list %}
+              {%- set _ = nodes.append(node.split('.')[0]) %}
+            {%- endfor %}
             - job_name: node
               static_configs:
-                {% for node in [
-                  'controller',
-                  'keep0',
-                  'workbench',
-                  'shell',
-                ] %}
+                {% for node in nodes %}
                 - targets: [ "{{ node }}.__DOMAIN__:9100" ]
                   labels:
                     instance: "{{ node }}.__CLUSTER__"
index d1aab048c1ac0de6ff69faf65acfc287b3cd1bc0..c16b9cc27ba4b61045f69f11da73e308b5365034 100644 (file)
@@ -102,6 +102,35 @@ NODES=(
   [shell.${DOMAIN}]=shell
 )
 
+# Comma-separated list of nodes. This is used to dynamically adjust
+# salt pillars.
+NODELIST=""
+for node in "${!NODES[@]}"; do
+  if [ -z "$NODELIST" ]; then
+    NODELIST="$node"
+  else
+    NODELIST="$NODELIST,$node"
+  fi
+done
+
+# The mapping of roles to nodes. This is used to dinamically adjust
+# salt pillars.
+declare -A ROLES
+for node in "${!NODES[@]}"; do
+  roles="${NODES[$node]}"
+
+  # Split the comma-separated roles into an array
+  IFS=',' read -ra roles_array <<< "$roles"
+
+  for role in "${roles_array[@]}"; do
+    if [ -n "${ROLES[$role]:-}" ]; then
+      ROLES["$role"]="${ROLES[$role]},$node"
+    else
+      ROLES["$role"]=$node
+    fi
+  done
+done
+
 # Host SSL port where you want to point your browser to access Arvados
 # Defaults to 443 for regular runs, and to 8443 when called in Vagrant.
 # You can point it to another port if desired
index 52a7f70ad3d20e368c73ce9f5cfa1bf3cbc32612..c79d16dec85737d4bce7134ef08a52ac96da254e 100755 (executable)
@@ -241,6 +241,8 @@ T_DIR="/tmp/cluster_tests"
 arguments ${@}
 
 declare -A NODES
+declare -A ROLES
+declare NODELIST
 
 if [[ -s ${CONFIG_FILE} && -s ${CONFIG_FILE}.secrets ]]; then
   source ${CONFIG_FILE}.secrets
@@ -466,6 +468,7 @@ for f in $(ls "${SOURCE_PILLARS_DIR}"/*); do
        s#__ENABLE_BALANCER__#${ENABLE_BALANCER}#g;
        s#__BALANCER_NODENAME__#${BALANCER_NODENAME}#g;
        s#__BALANCER_BACKENDS__#${BALANCER_BACKENDS}#g;
+       s#__NODELIST__#${NODELIST}#g;
        s#__DISPATCHER_INT_IP__#${DISPATCHER_INT_IP}#g;
        s#__KEEPBALANCE_INT_IP__#${KEEPBALANCE_INT_IP}#g;
        s#__COMPUTE_AMI__#${COMPUTE_AMI}#g;
@@ -557,6 +560,7 @@ if [ -d "${SOURCE_STATES_DIR}" ]; then
          s#__ENABLE_BALANCER__#${ENABLE_BALANCER}#g;
          s#__BALANCER_NODENAME__#${BALANCER_NODENAME}#g;
          s#__BALANCER_BACKENDS__#${BALANCER_BACKENDS}#g;
+         s#__NODELIST__#${NODELIST}#g;
          s#__DISPATCHER_INT_IP__#${DISPATCHER_INT_IP}#g;
          s#__KEEPBALANCE_INT_IP__#${KEEPBALANCE_INT_IP}#g;
          s#__COMPUTE_AMI__#${COMPUTE_AMI}#g;