From 30afb151e4fb89b3d70033ec4c5ebd16d28c60dd Mon Sep 17 00:00:00 2001 From: Salvatore Daniele Date: Thu, 31 Oct 2024 16:44:41 -0400 Subject: [PATCH] AssistedInstaller: Fix infinite loop We can't override list_clusters() to return an unexpected data type, because other functions in the base class rely on this. This causes an infinite loop when trying to call delete_cluster() Rename function to be more specific Signed-off-by: Salvatore Daniele --- assistedInstaller.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/assistedInstaller.py b/assistedInstaller.py index a450c664..b7c7d8b8 100644 --- a/assistedInstaller.py +++ b/assistedInstaller.py @@ -35,7 +35,7 @@ def __init__(self, url: str): super().__init__(url, quiet=True, debug=False) def cluster_exists(self, name: str) -> bool: - return any(name == x.name for x in self.list_clusters()) + return any(name == x.name for x in self.get_cluster_info_all()) def ensure_cluster_deleted(self, name: str) -> None: logger.info(f"Ensuring that cluster {name} is not present") @@ -120,8 +120,8 @@ def wait_cluster_ready(self, cluster_name: str) -> None: time.sleep(10) @tenacity.retry(wait=tenacity.wait_fixed(2), stop=tenacity.stop_after_attempt(5)) - def list_clusters(self) -> list[ClusterInfo]: - all_clusters = super().list_clusters() + def get_cluster_info_all(self) -> list[ClusterInfo]: + all_clusters = self.list_clusters() if not isinstance(all_clusters, list): raise Exception(f"Unexpected type for list_clusters: {type(all_clusters)}") @@ -137,7 +137,7 @@ def list_clusters(self) -> list[ClusterInfo]: return ret def cluster_state(self, cluster_name: str) -> str: - matching_clusters = [x for x in self.list_clusters() if x.name == cluster_name] + matching_clusters = [x for x in self.get_cluster_info_all() if x.name == cluster_name] if len(matching_clusters) == 0: logger.error(f"Requested status of cluster '{cluster_name}' but couldn't find it") sys.exit(-1)