Skip to content

Commit

Permalink
Set subprocess.run check to False if returncode is used later (#330)
Browse files Browse the repository at this point in the history
Co-authored-by: Jiawei "Tyler" Gu <[email protected]>
  • Loading branch information
qsdrqs and tylergu authored Feb 25, 2024
1 parent 1e1a46f commit 674438f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
8 changes: 4 additions & 4 deletions acto/kubernetes_engine/kind.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def create_cluster(self, name: str, kubeconfig: str):

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

p = subprocess.run(cmd, check=True)
p = subprocess.run(cmd, check=False)
i = 0
while p.returncode != 0:
if i == 3:
Expand All @@ -122,7 +122,7 @@ def create_cluster(self, name: str, kubeconfig: str):
i += 1
self.delete_cluster(name, kubeconfig)
time.sleep(5)
p = subprocess.run(cmd, check=True)
p = subprocess.run(cmd, check=False)

try:
kubernetes.config.load_kube_config(
Expand Down Expand Up @@ -154,7 +154,7 @@ def load_images(self, images_archive_path: str, name: str):
else:
logging.error("Missing cluster name for kind load")

p = subprocess.run(cmd + [images_archive_path], check=True)
p = subprocess.run(cmd + [images_archive_path], check=False)
if p.returncode != 0:
logging.error("Failed to preload images archive")

Expand All @@ -171,7 +171,7 @@ def delete_cluster(self, name: str, kubeconfig: str):
else:
raise RuntimeError("Missing kubeconfig for kind create")

while subprocess.run(cmd, check=True).returncode != 0:
while subprocess.run(cmd, check=False).returncode != 0:
continue

def get_node_list(self, name: str):
Expand Down
28 changes: 14 additions & 14 deletions acto/kubernetes_engine/minikube.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def create_cluster(self, name: str, kubeconfig: str):
cmd,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
check=True,
check=False,
)

i = 0
Expand All @@ -83,7 +83,7 @@ def create_cluster(self, name: str, kubeconfig: str):
i += 1
self.delete_cluster(name, kubeconfig)
time.sleep(5)
p = subprocess.run(cmd, check=True)
p = subprocess.run(cmd, check=False)

# csi driver
cmd = ["minikube", "addons", "disable", "storage-provisioner"]
Expand All @@ -93,7 +93,7 @@ def create_cluster(self, name: str, kubeconfig: str):
cmd,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
check=True,
check=False,
)
i = 0
print(cmd)
Expand All @@ -107,7 +107,7 @@ def create_cluster(self, name: str, kubeconfig: str):
i += 1
self.delete_cluster(name, kubeconfig)
time.sleep(5)
p = subprocess.run(cmd, check=True)
p = subprocess.run(cmd, check=False)

cmd = ["minikube", "addons", "disable", "default-storageclass"]
cmd.extend(["--profile", name])
Expand All @@ -116,7 +116,7 @@ def create_cluster(self, name: str, kubeconfig: str):
cmd,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
check=True,
check=False,
)
i = 0
print(cmd)
Expand All @@ -130,15 +130,15 @@ def create_cluster(self, name: str, kubeconfig: str):
i += 1
self.delete_cluster(name, kubeconfig)
time.sleep(5)
p = subprocess.run(cmd, check=True)
p = subprocess.run(cmd, check=False)

cmd = ["minikube", "addons", "enable", "volumesnapshots"]
cmd.extend(["--profile", name])
p = subprocess.run(
cmd,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
check=True,
check=False,
)
i = 0
print(cmd)
Expand All @@ -152,15 +152,15 @@ def create_cluster(self, name: str, kubeconfig: str):
i += 1
self.delete_cluster(name, kubeconfig)
time.sleep(5)
p = subprocess.run(cmd, check=True)
p = subprocess.run(cmd, check=False)

cmd = ["minikube", "addons", "enable", "csi-hostpath-driver"]
cmd.extend(["--profile", name])
p = subprocess.run(
cmd,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
check=True,
check=False,
)
i = 0
print(cmd)
Expand All @@ -174,7 +174,7 @@ def create_cluster(self, name: str, kubeconfig: str):
i += 1
self.delete_cluster(name, kubeconfig)
time.sleep(5)
p = subprocess.run(cmd, check=True)
p = subprocess.run(cmd, check=False)

cmd = [
"kubectl",
Expand All @@ -188,7 +188,7 @@ def create_cluster(self, name: str, kubeconfig: str):
cmd,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
check=True,
check=False,
)
i = 0
print(cmd)
Expand All @@ -202,7 +202,7 @@ def create_cluster(self, name: str, kubeconfig: str):
i += 1
self.delete_cluster(name, kubeconfig)
time.sleep(5)
p = subprocess.run(cmd, check=True)
p = subprocess.run(cmd, check=False)

# minikube mount
cmd = ["minikube", "mount", "profile/data:/tmp/profile"]
Expand Down Expand Up @@ -239,7 +239,7 @@ def load_images(self, images_archive_path: str, name: str):
else:
logging.error("Missing cluster name for minikube load")

p = subprocess.run(cmd + [images_archive_path], check=True)
p = subprocess.run(cmd + [images_archive_path], check=False)
if p.returncode != 0:
logging.error("Failed to preload images archive")

Expand All @@ -257,7 +257,7 @@ def delete_cluster(self, name: str, kubeconfig: str):
else:
raise RuntimeError("Missing kubeconfig for minikube create")

while subprocess.run(cmd, check=True).returncode != 0:
while subprocess.run(cmd, check=False).returncode != 0:
continue

os.environ.pop("KUBECONFIG", None)
Expand Down

0 comments on commit 674438f

Please sign in to comment.