From 5636e7f5a112fd8150c0f2ce9a846492397a6d3a Mon Sep 17 00:00:00 2001 From: Julia Yakovlev Date: Mon, 20 May 2024 19:51:10 +0300 Subject: [PATCH] fix(cluster): ipv6 address in network_interfaces object The problem was found during IPv6 test. IPv6 was converted to full format when parse nodetool status result. This change was represented by https://github.com/scylladb/scylla-cluster-tests/pull/7047 But IPv6 address was not converted when collected info about nodes network interfaces (AWS). During checking nodes status, we compare between 'nodetool status' output and node address that kept in the network_interfaces object. It fails because the IPv6 address miss leading zeros. As result the test fails with errors 'Failed to find a node in cluster by IP' Also fix the same problem for peer and gossip output. Fixes: https://github.com/scylladb/scylla-cluster-tests/issues/7447 --- sdcm/cluster.py | 6 ++++-- sdcm/cluster_aws.py | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/sdcm/cluster.py b/sdcm/cluster.py index 6540fbc6cc..8f4b7f5a4b 100644 --- a/sdcm/cluster.py +++ b/sdcm/cluster.py @@ -2742,7 +2742,8 @@ def get_peers_info(self): for row in cql_results: peer = row.peer try: - ipaddress.ip_address(row.peer) + # make sure we use ipv6 long format (some tools remove leading zeros) + peer = ipaddress.ip_address(row.peer).exploded except ValueError as exc: current_err = f"Peer '{peer}' is not an IP address, err: {exc}\n" LOGGER.warning(current_err) @@ -2774,7 +2775,8 @@ def get_gossip_info(self) -> dict[BaseNode, dict]: if line.startswith('SCHEMA:'): schema = line.replace('SCHEMA:', '') elif line.startswith('RPC_ADDRESS:'): - ip = line.replace('RPC_ADDRESS:', '') + # make sure we use ipv6 long format (some tools remove leading zeros) + ip = ipaddress.ip_address(line.replace('RPC_ADDRESS:', '')).exploded elif line.startswith('STATUS:'): status = line.replace('STATUS:', '').split(',')[0] elif line.startswith('DC:'): diff --git a/sdcm/cluster_aws.py b/sdcm/cluster_aws.py index 63d21a5c2e..3bd04df74d 100644 --- a/sdcm/cluster_aws.py +++ b/sdcm/cluster_aws.py @@ -12,7 +12,7 @@ # Copyright (c) 2020 ScyllaDB # pylint: disable=too-many-lines, too-many-public-methods - +import ipaddress import json import logging import os @@ -460,7 +460,9 @@ def network_interfaces(self): for interface in self._instance.network_interfaces: private_ip_addresses = [private_address["PrivateIpAddress"] for private_address in interface.private_ip_addresses] - ipv6_addresses = [ipv6_address['Ipv6Address'] for ipv6_address in interface.ipv6_addresses] + # make sure we use ipv6 long format (some tools remove leading zeros) + ipv6_addresses = [ipaddress.ip_address( + ipv6_address['Ipv6Address']).exploded for ipv6_address in interface.ipv6_addresses] device_indexes.append(interface.attachment['DeviceIndex']) ipv4_public_address = interface.association_attribute['PublicIp'] if interface.association_attribute else None dns_public_name = interface.association_attribute['PublicDnsName'] if interface.association_attribute else None