Skip to content

Commit

Permalink
fix(multinetwork): remove second network interface configuration
Browse files Browse the repository at this point in the history
After multiple hard reboots a node eventually loses connection to all other nodes in the cluster.
After node reboot, 2nd interface isn't functioning.
Found that our `sdcm.provision.aws.utils.configure_eth1_script` re-configure the second network interface and it causes
to lost connection.
Actually with using existing and configured network interface we do not need this eth1 configuration script any more.

Fixes: scylladb#8553
  • Loading branch information
juliayakovlev committed Sep 30, 2024
1 parent 03eb8b0 commit 915cfc9
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 77 deletions.
4 changes: 1 addition & 3 deletions sdcm/provision/aws/configuration_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# Copyright (c) 2021 ScyllaDB

from sdcm.provision.aws.utils import network_config_ipv6_workaround_script, configure_eth1_script
from sdcm.provision.aws.utils import network_config_ipv6_workaround_script
from sdcm.provision.common.configuration_script import ConfigurationScriptBuilder


Expand All @@ -27,8 +27,6 @@ def _wait_before_running_script(self) -> str:

def _script_body(self) -> str:
script = super()._script_body()
if self.aws_additional_interface:
script += configure_eth1_script()
if self.aws_ipv6_workaround:
script += network_config_ipv6_workaround_script()
return script
74 changes: 0 additions & 74 deletions sdcm/provision/aws/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,80 +283,6 @@ def network_config_ipv6_workaround_script():
""")


def configure_eth1_script():
return dedent(r"""
if grep -qi "ubuntu" /etc/os-release; then
ETH1_IP_ADDRESS=`ip route show | grep eth1 | grep -oPm1 'src \K[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*'`
ETH1_CIDR_BLOCK=`ip route show | grep eth1 | grep -oPm1 '\K[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*/[0-9]*'`
ETH1_SUBNET=`echo ${ETH1_CIDR_BLOCK} | grep -oP '\\K/\\d+'`
bash -c "echo '
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: yes
dhcp6: yes
eth1:
addresses:
- ${ETH1_IP_ADDRESS}${ETH1_SUBNET}
dhcp4: no
dhcp6: no
routes:
- to: 0.0.0.0/0
via: 10.0.0.1 # Default gateway
table: 2
- to: ${ETH1_CIDR_BLOCK}
scope: link
table: 2
routing-policy:
- from: ${ETH1_IP_ADDRESS}/32
table: 2
' > /etc/netplan/51-eth1.yaml"
netplan --debug apply
else
TOKEN=$(curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 600")
BASE_EC2_NETWORK_URL=http://169.254.169.254/latest/meta-data/network/interfaces/macs/
NUMBER_OF_ENI=`curl -s -H "X-aws-ec2-metadata-token: ${TOKEN}" ${BASE_EC2_NETWORK_URL} | wc -w`
for mac in `curl -s -H "X-aws-ec2-metadata-token: ${TOKEN}" ${BASE_EC2_NETWORK_URL}`
do
DEVICE_NUMBER=`curl -s -H "X-aws-ec2-metadata-token: ${TOKEN}" ${BASE_EC2_NETWORK_URL}${mac}/device-number`
if [[ "$DEVICE_NUMBER" == "1" ]]; then
ETH1_MAC=${mac}
fi
done
if [[ ! "${DEVICE_NUMBER}x" == "x" ]]; then
ETH1_IP_ADDRESS=`curl -s -H "X-aws-ec2-metadata-token: ${TOKEN}" ${BASE_EC2_NETWORK_URL}${ETH1_MAC}/local-ipv4s`
ETH1_CIDR_BLOCK=`curl -s -H "X-aws-ec2-metadata-token: ${TOKEN}" ${BASE_EC2_NETWORK_URL}${ETH1_MAC}/subnet-ipv4-cidr-block`
fi
bash -c "echo 'GATEWAYDEV=eth0' >> /etc/sysconfig/network"
echo "
DEVICE="eth1"
BOOTPROTO="dhcp"
ONBOOT="yes"
TYPE="Ethernet"
USERCTL="yes"
PEERDNS="yes"
IPV6INIT="no"
PERSISTENT_DHCLIENT="1"
" > /etc/sysconfig/network-scripts/ifcfg-eth1
echo "
default via 10.0.0.1 dev eth1 table 2
${ETH1_CIDR_BLOCK} dev eth1 src ${ETH1_IP_ADDRESS} table 2
" > /etc/sysconfig/network-scripts/route-eth1
echo "
from ${ETH1_IP_ADDRESS}/32 table 2
" > /etc/sysconfig/network-scripts/rule-eth1
systemctl restart network
fi
""")


def configure_set_preserve_hostname_script():
return 'grep "preserve_hostname: true" /etc/cloud/cloud.cfg 1>/dev/null 2>&1 ' \
'|| echo "preserve_hostname: true" >> /etc/cloud/cloud.cfg\n'
Expand Down

0 comments on commit 915cfc9

Please sign in to comment.