Skip to content

Commit 7a03bce

Browse files
committed
improve code flow
Signed-off-by: mahdikhashan <[email protected]>
1 parent d6c7319 commit 7a03bce

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

sdk/python/v1beta1/kubeflow/katib/api/katib_client.py

+2-11
Original file line numberDiff line numberDiff line change
@@ -575,17 +575,8 @@ class name in this argument.
575575
f"alphanumeric characters ('a-z', '0-9'), hyphens ('-'), or periods ('.'). "
576576
f"It must also start and end with an alphanumeric character."
577577
)
578-
579-
pvc_list = self.core_api.list_namespaced_persistent_volume_claim(
580-
namespace=namespace
581-
)
582-
# Check if the PVC with the specified name exists.
583-
for pvc in pvc_list.items:
584-
if pvc.metadata.name == name:
585-
print(
586-
f"PVC '{name}' already exists in namespace " f"{namespace}."
587-
)
588-
break
578+
elif hasattr(e, "status") and e.status == 409:
579+
print(f"PVC '{name}' already exists in namespace " f"{namespace}.")
589580
else:
590581
raise RuntimeError(f"failed to create PVC. Error: {e}")
591582

0 commit comments

Comments
 (0)