Skip to content

Commit 30afb15

Browse files
committed
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 <[email protected]>
1 parent 48f5838 commit 30afb15

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

assistedInstaller.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def __init__(self, url: str):
3535
super().__init__(url, quiet=True, debug=False)
3636

3737
def cluster_exists(self, name: str) -> bool:
38-
return any(name == x.name for x in self.list_clusters())
38+
return any(name == x.name for x in self.get_cluster_info_all())
3939

4040
def ensure_cluster_deleted(self, name: str) -> None:
4141
logger.info(f"Ensuring that cluster {name} is not present")
@@ -120,8 +120,8 @@ def wait_cluster_ready(self, cluster_name: str) -> None:
120120
time.sleep(10)
121121

122122
@tenacity.retry(wait=tenacity.wait_fixed(2), stop=tenacity.stop_after_attempt(5))
123-
def list_clusters(self) -> list[ClusterInfo]:
124-
all_clusters = super().list_clusters()
123+
def get_cluster_info_all(self) -> list[ClusterInfo]:
124+
all_clusters = self.list_clusters()
125125
if not isinstance(all_clusters, list):
126126
raise Exception(f"Unexpected type for list_clusters: {type(all_clusters)}")
127127

@@ -137,7 +137,7 @@ def list_clusters(self) -> list[ClusterInfo]:
137137
return ret
138138

139139
def cluster_state(self, cluster_name: str) -> str:
140-
matching_clusters = [x for x in self.list_clusters() if x.name == cluster_name]
140+
matching_clusters = [x for x in self.get_cluster_info_all() if x.name == cluster_name]
141141
if len(matching_clusters) == 0:
142142
logger.error(f"Requested status of cluster '{cluster_name}' but couldn't find it")
143143
sys.exit(-1)

0 commit comments

Comments
 (0)