-
Notifications
You must be signed in to change notification settings - Fork 459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SDK] improve PVC creation name error #2496
Changes from 5 commits
ff3de2b
eea6de6
33028c1
516b4b5
651b231
86a1841
d6c7319
7a03bce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -569,6 +569,11 @@ class name in this argument. | |||||||||
), | ||||||||||
) | ||||||||||
except Exception as e: | ||||||||||
if hasattr(e, "status") and e.status == 422: | ||||||||||
raise ValueError( | ||||||||||
f"An Experiment with the name {name} is not valid." | ||||||||||
) | ||||||||||
|
||||||||||
pvc_list = self.core_api.list_namespaced_persistent_volume_claim( | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we also simplify this logic similar to this one: katib/sdk/python/v1beta1/kubeflow/katib/api/katib_client.py Lines 140 to 143 in d6c7319
E.g. if status_code is 409 we just print that PVC already exists. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we add more details to the error message, it’ll make it easier for users to understand, which is the goal of this PR. But you’re right—Kubernetes API will also return detailed error reasons. So it depends on whether we want to keep the error messages consistent across the board. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My opinion is a bit more leaned to Helens. But I'm open to any changes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just meant that all of these: pvc_list = self.core_api.list_namespaced_persistent_volume_claim(
namespace=namespace
)
# Check if the PVC with the specified name exists.
for pvc in pvc_list.items:
if pvc.metadata.name == name:
print(
f"PVC '{name}' already exists in namespace " f"{namespace}."
)
break
else:
raise RuntimeError(f"failed to create PVC. Error: {e}") can be replaced to elif hasattr(e, "status") and e.status == 409:
print(f"PVC '{name}' already exists in namespace " f"{namespace}.")
else:
raise RuntimeError(f"failed to create PVC. Error: {e}") Does it make sense ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh I see, SGTM 😄 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, agreed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done. |
||||||||||
namespace=namespace | ||||||||||
) | ||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking we should move this check after this line since the error belongs to that scenario:
katib/sdk/python/v1beta1/kubeflow/katib/api/katib_client.py
Line 582 in 40e1e65
Additionally, to make the error easier to understand, we could tweak the error message a bit. How about this:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with the ValueError message (with a bit of change), with combining it with else, not really - since then we need to wait for this steps first:
so my idea is the function fails fast when the name is invalid then if its valid, continues with the check for the existence of the name. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense.