From b9b112641832065d18e10af7b386e9e30d9c8802 Mon Sep 17 00:00:00 2001 From: Denise Perez Date: Mon, 20 May 2024 11:55:31 +0300 Subject: [PATCH] fix: change eth to ens for aws --- bash_functions/get_bash_function.go | 25 +++++++++++++++---------- deploy/deploy_backend.go | 20 ++++++++++++++------ join/join.go | 23 +++++++++++++++-------- 3 files changed, 44 insertions(+), 24 deletions(-) diff --git a/bash_functions/get_bash_function.go b/bash_functions/get_bash_function.go index fb176ee..7cc2c7b 100644 --- a/bash_functions/get_bash_function.go +++ b/bash_functions/get_bash_function.go @@ -76,27 +76,32 @@ func GetNetStrForDpdk() string { function getNetStrForDpdk() { i=$1 j=$2 - gateways=$3 - gateways=($gateways) #azure and gcp + interface_str=$3 + gateways=$4 + #gateways=($gateways) #azure and gcp + IFS=' ' read -r -a gateways <<< "$gateways" net="" + gateway_index=1 for ((i; i<$j; i++)); do - eth=eth$i - subnet_inet=$(ifconfig $eth | grep 'inet ' | awk '{print $2}') + interface=$interface_str$i + subnet_inet=$(ifconfig $interface | grep 'inet ' | awk '{print $2}') if [ -z $subnet_inet ] || [ ${#gateways[@]} -eq 0 ];then - net="$net --net $eth" #aws + net="$net --net $interface" #aws continue fi - enp=$(ls -l /sys/class/net/$eth/ | grep lower | awk -F"_" '{print $2}' | awk '{print $1}') #for azure + enp=$(ls -l /sys/class/net/$interface/ | grep lower | awk -F"_" '{print $2}' | awk '{print $1}') #for azure if [ -z $enp ];then - enp=$(ethtool -i $eth | grep bus-info | awk '{print $2}') #pci for gcp + enp=$(ethtool -i $interface | grep bus-info | awk '{print $2}') #pci for gcp fi - bits=$(ip -o -f inet addr show $eth | awk '{print $4}') + bits=$(ip -o -f inet addr show $interface | awk '{print $4}') IFS='/' read -ra netmask <<< "$bits" - - gateway=${gateways[$i]} + + gateway=${gateways["$gateway_index"]} net="$net --net $enp/$subnet_inet/${netmask[1]}/$gateway" + gateway_index=$(($gateway_index+1)) done + echo $net } ` return dedent.Dedent(s) diff --git a/deploy/deploy_backend.go b/deploy/deploy_backend.go index b6a06ff..e6be7d5 100644 --- a/deploy/deploy_backend.go +++ b/deploy/deploy_backend.go @@ -66,12 +66,20 @@ func (d *DeployScriptGenerator) GetBackendDeployScript() string { get_core_ids $COMPUTE_CONTAINER_CORES_NUM compute_core_ids total_containers=2 + + IFS=$'\n' interfaces=($(ls /sys/class/net | grep -v lo | grep -v docker0 | grep -v enP | sort)) + second_interface=${interfaces[1]} + interface_num=$(echo "${second_interface:3}") + interface_str=$(echo "${second_interface::-1}") if [[ $INSTALL_DPDK == true ]]; then - getNetStrForDpdk 1 $(($DRIVE_CONTAINER_CORES_NUM+1)) "$GATEWAYS" - sudo weka local setup container --name drives0 --base-port 14000 --cores $DRIVE_CONTAINER_CORES_NUM --no-frontends --drives-dedicated-cores $DRIVE_CONTAINER_CORES_NUM --failure-domain $FAILURE_DOMAIN --core-ids $drive_core_ids --dedicate $net - getNetStrForDpdk $((1+$DRIVE_CONTAINER_CORES_NUM)) $((1+$DRIVE_CONTAINER_CORES_NUM+$COMPUTE_CONTAINER_CORES_NUM )) "$GATEWAYS" - sudo weka local setup container --name compute0 --base-port 15000 --cores $COMPUTE_CONTAINER_CORES_NUM --no-frontends --compute-dedicated-cores $COMPUTE_CONTAINER_CORES_NUM --memory $COMPUTE_MEMORY --failure-domain $FAILURE_DOMAIN --core-ids $compute_core_ids --dedicate $net + net_value=$(getNetStrForDpdk $interface_num $(($DRIVE_CONTAINER_CORES_NUM+$interface_num)) $interface_str "$GATEWAYS") + + sudo weka local setup container --name drives0 --base-port 14000 --cores $DRIVE_CONTAINER_CORES_NUM --no-frontends --drives-dedicated-cores $DRIVE_CONTAINER_CORES_NUM --failure-domain $FAILURE_DOMAIN --core-ids $drive_core_ids --dedicate $net_value + + net_value=$(getNetStrForDpdk $(($interface_num+$DRIVE_CONTAINER_CORES_NUM)) $(($DRIVE_CONTAINER_CORES_NUM+$COMPUTE_CONTAINER_CORES_NUM+$interface_num )) "$interface_str" "$GATEWAYS") + cmd="weka local setup container --name compute0 --base-port 15000 --cores $COMPUTE_CONTAINER_CORES_NUM --no-frontends --compute-dedicated-cores $COMPUTE_CONTAINER_CORES_NUM --memory $COMPUTE_MEMORY --failure-domain $FAILURE_DOMAIN --core-ids $compute_core_ids --dedicate $net_value" + $cmd else sudo weka local setup container --name drives0 --base-port 14000 --cores $DRIVE_CONTAINER_CORES_NUM --no-frontends --drives-dedicated-cores $DRIVE_CONTAINER_CORES_NUM --failure-domain $FAILURE_DOMAIN --core-ids $drive_core_ids --dedicate --net udp sudo weka local setup container --name compute0 --base-port 15000 --cores $COMPUTE_CONTAINER_CORES_NUM --no-frontends --compute-dedicated-cores $COMPUTE_CONTAINER_CORES_NUM --memory $COMPUTE_MEMORY --failure-domain $FAILURE_DOMAIN --core-ids $compute_core_ids --dedicate --net udp @@ -81,8 +89,8 @@ func (d *DeployScriptGenerator) GetBackendDeployScript() string { total_containers=3 get_core_ids $FRONTEND_CONTAINER_CORES_NUM frontend_core_ids if [[ $INSTALL_DPDK == true ]]; then - getNetStrForDpdk $(($NICS_NUM-1)) $(($NICS_NUM)) "$GATEWAYS" "$SUBNETS" - sudo weka local setup container --name frontend0 --base-port 16000 --cores $FRONTEND_CONTAINER_CORES_NUM --frontend-dedicated-cores $FRONTEND_CONTAINER_CORES_NUM --allow-protocols true --failure-domain $FAILURE_DOMAIN --core-ids $frontend_core_ids --dedicate $net + net_value=$(getNetStrForDpdk $(($interface_num+$DRIVE_CONTAINER_CORES_NUM+$COMPUTE_CONTAINER_CORES_NUM)) $(($interface_num+$NICS_NUM-1)) "$interface_str" "$GATEWAYS" "$SUBNETS") + sudo weka local setup container --name frontend0 --base-port 16000 --cores $FRONTEND_CONTAINER_CORES_NUM --frontend-dedicated-cores $FRONTEND_CONTAINER_CORES_NUM --allow-protocols true --failure-domain $FAILURE_DOMAIN --core-ids $frontend_core_ids --dedicate $net_value else sudo weka local setup container --name frontend0 --base-port 16000 --cores $FRONTEND_CONTAINER_CORES_NUM --frontend-dedicated-cores $FRONTEND_CONTAINER_CORES_NUM --allow-protocols true --failure-domain $FAILURE_DOMAIN --core-ids $frontend_core_ids --dedicate --net udp fi diff --git a/join/join.go b/join/join.go index 9187d14..57ebc1e 100644 --- a/join/join.go +++ b/join/join.go @@ -94,11 +94,14 @@ func (j *JoinScriptGenerator) GetJoinScript(ctx context.Context) string { fi fi done + + IFS=$'\n' interfaces=($(ls /sys/class/net | grep -v lo | grep -v docker0 | grep -v enP | sort)) + first_interface="${interfaces[0]}" - ip=$(ifconfig eth0 | grep "inet " | awk '{ print $2}') + ip=$(ifconfig $first_interface | grep "inet " | awk '{ print $2}') while [ ! $ip ] ; do sleep 1 - ip=$(ifconfig eth0 | grep "inet " | awk '{ print $2}') + ip=$(ifconfig $first_interface | grep "inet " | awk '{ print $2}') done report "{\"hostname\": \"$HOSTNAME\", \"type\": \"progress\", \"message\": \"Installing weka\"}" @@ -116,12 +119,16 @@ func (j *JoinScriptGenerator) GetJoinScript(ctx context.Context) string { get_core_ids $DRIVES drive_core_ids get_core_ids $COMPUTE compute_core_ids + second_interface="${interfaces[1]}" + interface_num=$(echo "${second_interface:3}") + interface_str=$(echo "${second_interface::-1}") + mgmt_ip=$(hostname -I | awk '{print $1}') if [[ $INSTALL_DPDK == true ]]; then - getNetStrForDpdk 1 $(($DRIVES+1)) "$GATEWAYS" - sudo weka local setup container --name drives0 --base-port 14000 --cores $DRIVES --no-frontends --drives-dedicated-cores $DRIVES --join-ips $host_ips --failure-domain "$HASHED_IP" --core-ids $drive_core_ids --management-ips $mgmt_ip --dedicate $net - getNetStrForDpdk $((1+$DRIVES)) $((1+$DRIVES+$COMPUTE)) "$GATEWAYS" - sudo weka local setup container --name compute0 --base-port 15000 --cores $COMPUTE --memory "$COMPUTE_MEMORY" --no-frontends --compute-dedicated-cores $COMPUTE --join-ips $host_ips --failure-domain "$HASHED_IP" --core-ids $compute_core_ids --management-ips $mgmt_ip --dedicate $net + net_value=$(getNetStrForDpdk $interface_num $(($DRIVES+$interface_num)) "$interface_str" "$GATEWAYS") + sudo weka local setup container --name drives0 --base-port 14000 --cores $DRIVES --no-frontends --drives-dedicated-cores $DRIVES --join-ips $host_ips --failure-domain "$HASHED_IP" --core-ids $drive_core_ids --management-ips $mgmt_ip --dedicate $net_value + net_value=$(getNetStrForDpdk $(($interface_num+$DRIVES)) $(($interface_num+$DRIVES+$COMPUTE)) "$interface_str" "$GATEWAYS") + sudo weka local setup container --name compute0 --base-port 15000 --cores $COMPUTE --memory "$COMPUTE_MEMORY" --no-frontends --compute-dedicated-cores $COMPUTE --join-ips $host_ips --failure-domain "$HASHED_IP" --core-ids $compute_core_ids --management-ips $mgmt_ip --dedicate $net_value else sudo weka local setup container --name drives0 --base-port 14000 --cores $DRIVES --no-frontends --drives-dedicated-cores $DRIVES --join-ips $host_ips --failure-domain "$HASHED_IP" --core-ids $drive_core_ids --management-ips $mgmt_ip --dedicate --net udp sudo weka local setup container --name compute0 --base-port 15000 --cores $COMPUTE --memory "$COMPUTE_MEMORY" --no-frontends --compute-dedicated-cores $COMPUTE --join-ips $host_ips --failure-domain "$HASHED_IP" --core-ids $compute_core_ids --management-ips $mgmt_ip --dedicate --net udp @@ -130,8 +137,8 @@ func (j *JoinScriptGenerator) GetJoinScript(ctx context.Context) string { if [[ $FRONTEND -gt 0 ]]; then get_core_ids $FRONTEND frontend_core_ids if [[ $INSTALL_DPDK == true ]]; then - getNetStrForDpdk $((1+$DRIVES+$COMPUTE)) $((1+$DRIVES+$COMPUTE+1)) "$GATEWAYS" - sudo weka local setup container --name frontend0 --base-port 16000 --cores $FRONTEND --allow-protocols true --frontend-dedicated-cores $FRONTEND --join-ips $host_ips --failure-domain "$HASHED_IP" --core-ids $frontend_core_ids --management-ips $mgmt_ip --dedicate $net + net_value=$(getNetStrForDpdk $(($interface_num+$DRIVES+$COMPUTE)) $(($interface_num+$DRIVES+$COMPUTE+1)) "$interface_str" "$GATEWAYS") + sudo weka local setup container --name frontend0 --base-port 16000 --cores $FRONTEND --allow-protocols true --frontend-dedicated-cores $FRONTEND --join-ips $host_ips --failure-domain "$HASHED_IP" --core-ids $frontend_core_ids --management-ips $mgmt_ip --dedicate $net_value else sudo weka local setup container --name frontend0 --base-port 16000 --cores $FRONTEND --allow-protocols true --frontend-dedicated-cores $FRONTEND --join-ips $host_ips --failure-domain "$HASHED_IP" --core-ids $frontend_core_ids --management-ips $mgmt_ip --dedicate --net udp fi