Skip to content

Commit

Permalink
fix(gce-logcollector): use private addresses as default
Browse files Browse the repository at this point in the history
since now we are working as default with private addresses in
gcp and the public addresses can't be used, we now need to use
private addresses for the log collecting

similar fix as in 930c31 for aws

(cherry picked from commit f3c3c02)
  • Loading branch information
fruch committed May 30, 2024
1 parent 9572e84 commit 0eed6e2
Showing 1 changed file with 14 additions and 19 deletions.
33 changes: 14 additions & 19 deletions sdcm/logcollector.py
Original file line number Diff line number Diff line change
Expand Up @@ -1540,52 +1540,47 @@ def get_aws_instances_by_testid(self):
global_ip=self.get_aws_ip_address(instance),
tags={**self.tags, "NodeType": "loader", }))

@staticmethod
def gce_first_public_ip(instance):
return gce_public_addresses(instance)[0]

@staticmethod
def gce_first_private_ip(instance):
return gce_private_addresses(instance)[0]
def get_gce_ip_address(self, instance):
return gce_public_addresses(instance)[0] if ssh_connection_ip_type(self.params) == 'public' else gce_private_addresses(instance)[0]

def get_gce_instances_by_testid(self):
instances = list_instances_gce({"TestId": self.test_id}, running=True)
filtered_instances = filter_gce_instances_by_type(instances)
for instance in filtered_instances['db_nodes']:
self.db_cluster.append(CollectingNode(name=instance.name,
ssh_login_info={
"hostname": self.gce_first_private_ip(instance),
"hostname": self.get_gce_ip_address(instance),
"user": self.params.get('gce_image_username'),
"key_file": self.params.get('user_credentials_path')},
instance=instance,
global_ip=self.gce_first_public_ip(instance),
global_ip=self.get_gce_ip_address(instance),
tags={**self.tags, "NodeType": "scylla-db", }))
for instance in filtered_instances['monitor_nodes']:
self.monitor_set.append(CollectingNode(name=instance.name,
ssh_login_info={
"hostname": self.gce_first_private_ip(instance),
"hostname": self.get_gce_ip_address(instance),
"user": self.params.get('gce_image_username'),
"key_file": self.params.get('user_credentials_path')},
instance=instance,
global_ip=self.gce_first_public_ip(instance),
global_ip=self.get_gce_ip_address(instance),
tags={**self.tags, "NodeType": "monitor", }))
for instance in filtered_instances['loader_nodes']:
self.loader_set.append(CollectingNode(name=instance.name,
ssh_login_info={
"hostname": self.gce_first_private_ip(instance),
"hostname": self.get_gce_ip_address(instance),
"user": self.params.get('gce_image_username'),
"key_file": self.params.get('user_credentials_path')},
instance=instance,
global_ip=self.gce_first_public_ip(instance),
global_ip=self.get_gce_ip_address(instance),
tags={**self.tags, "NodeType": "loader", }))
for instance in filtered_instances['kubernetes_nodes']:
self.kubernetes_set.append(CollectingNode(name=instance.name,
ssh_login_info={
"hostname": self.gce_first_private_ip(instance),
"hostname": self.get_gce_ip_address(instance),
"user": self.params.get('gce_image_username'),
"key_file": self.params.get('user_credentials_path')},
instance=instance,
global_ip=self.gce_first_public_ip(instance),
global_ip=self.get_gce_ip_address(instance),
tags={**self.tags, "NodeType": "loader", }))
if self.params.get("use_cloud_manager"):
self.find_and_append_cloud_manager_instance_to_collecting_nodes()
Expand Down Expand Up @@ -1621,11 +1616,11 @@ def get_docker_instances_by_testid(self):
for instance in filtered_instances['db_nodes']:
self.db_cluster.append(CollectingNode(name=instance.name,
ssh_login_info={
"hostname": self.gce_first_public_ip(instance),
"hostname": self.get_gce_ip_address(instance),
"user": 'scylla-test',
"key_file": self.params.get('user_credentials_path')},
instance=instance,
global_ip=self.gce_first_public_ip(instance),
global_ip=self.get_gce_ip_address(instance),
tags={**self.tags, "NodeType": "scylla-db", }))
self.monitor_set.append(CollectingNode(name=f"monitor-node-{self.test_id}-0",
global_ip='127.0.0.1',
Expand All @@ -1634,11 +1629,11 @@ def get_docker_instances_by_testid(self):
for instance in filtered_instances['loader_nodes']:
self.loader_set.append(CollectingNode(name=instance.name,
ssh_login_info={
"hostname": self.gce_first_public_ip(instance),
"hostname": self.get_gce_ip_address(instance),
"user": 'scylla-test',
"key_file": self.params.get('user_credentials_path')},
instance=instance,
global_ip=self.gce_first_public_ip(instance),
global_ip=self.get_gce_ip_address(instance),
tags={**self.tags, "NodeType": "loader", }))

def get_running_cluster_sets(self, backend):
Expand Down

0 comments on commit 0eed6e2

Please sign in to comment.