Skip to content

Commit

Permalink
AssistedInstaller: Fix infinite loop
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
SalDaniele committed Oct 31, 2024
1 parent 48f5838 commit 30afb15
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions assistedInstaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)}")

Expand All @@ -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)
Expand Down

0 comments on commit 30afb15

Please sign in to comment.