Skip to content

Commit

Permalink
Add simple counter to bypass infinite loop for cluster set up testing
Browse files Browse the repository at this point in the history
  • Loading branch information
hzeng21 authored and tylergu committed Nov 4, 2023
1 parent daeebcc commit 1102aa8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 4 additions & 3 deletions acto/kubernetes_engine/kind.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,12 @@ def create_cluster(self, name: str, kubeconfig: str):

if self._k8s_version != "":
cmd.extend(['--image', f"kindest/node:{self._k8s_version}"])

i = 3

p = subprocess.run(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
while p.returncode != 0:
# TODO: retry for three times
while p.returncode != 0 and i != 0:
logging.error('Failed to create kind cluster, retrying')
i -= 1
self.delete_cluster(name, kubeconfig)
time.sleep(5)
p = subprocess.run(cmd)
Expand Down
5 changes: 4 additions & 1 deletion acto/kubernetes_engine/minikube.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,11 @@ def create_cluster(self, name: str, kubeconfig: str):
if self._k8s_version != "":
cmd.extend(['--kubernetes-version', str(self._k8s_version)])
p = subprocess.run(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
while p.returncode != 0:

i = 1
while p.returncode != 0 and i != 0:
logging.error('Failed to create minikube cluster, retrying')
i -= 1
self.delete_cluster(name, kubeconfig)
time.sleep(5)
p = subprocess.run(cmd)
Expand Down

0 comments on commit 1102aa8

Please sign in to comment.