diff --git a/acto/kubernetes_engine/kind.py b/acto/kubernetes_engine/kind.py index bcdc37b11..44af39a87 100644 --- a/acto/kubernetes_engine/kind.py +++ b/acto/kubernetes_engine/kind.py @@ -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) diff --git a/acto/kubernetes_engine/minikube.py b/acto/kubernetes_engine/minikube.py index 011a120ba..d600637e2 100644 --- a/acto/kubernetes_engine/minikube.py +++ b/acto/kubernetes_engine/minikube.py @@ -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)