Skip to content

Commit

Permalink
fix(cluster): ipv6 address in network_interfaces object
Browse files Browse the repository at this point in the history
The problem was found during IPv6 test.
IPv6 was converted to full format when parse nodetool status result.
This change was represented by  #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: #7447
  • Loading branch information
juliayakovlev authored and fruch committed May 21, 2024
1 parent ebdbf8a commit 5636e7f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions sdcm/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:'):
Expand Down
6 changes: 4 additions & 2 deletions sdcm/cluster_aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5636e7f

Please sign in to comment.