Skip to content

Commit

Permalink
fix: change eth to ens for aws
Browse files Browse the repository at this point in the history
  • Loading branch information
Denise Perez committed Sep 2, 2024
1 parent daac1ef commit ad865d3
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 23 deletions.
23 changes: 13 additions & 10 deletions bash_functions/get_bash_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,26 +76,29 @@ 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=0
for ((i; i<$j; i++)); do
eth=eth$i
subnet_inet=$(ifconfig $eth | grep 'inet ' | awk '{print $2}')
subnet_inet=$(ifconfig $interface_str$i | grep 'inet ' | awk '{print $2}')
if [ -z $subnet_inet ] || [ ${#gateways[@]} -eq 0 ];then
net="$net --net $eth" #aws
net="$net --net $interface_str$i" #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_str$i/ | 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_str$i | 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
}
`
Expand Down
16 changes: 11 additions & 5 deletions deploy/deploy_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,18 @@ 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"
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
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
getNetStrForDpdk $(($interface_num+$DRIVE_CONTAINER_CORES_NUM)) $(($DRIVE_CONTAINER_CORES_NUM+$COMPUTE_CONTAINER_CORES_NUM+$interface_num )) "$interface_str" "$GATEWAYS"
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
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
Expand All @@ -81,8 +87,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
Expand Down
23 changes: 15 additions & 8 deletions join/join.go
Original file line number Diff line number Diff line change
Expand Up @@ -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\"}"
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit ad865d3

Please sign in to comment.