-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
WebShared: Update how request checkout handles kube resource related errors #48168
Conversation
This pull request is automatically being deployed by Amplify Hosting (learn more). |
...ckages/shared/components/AccessRequests/NewRequest/RequestCheckout/RequestCheckout.story.tsx
Show resolved
Hide resolved
isResourceRequest={true} | ||
fetchResourceRequestRolesAttempt={{ | ||
status: 'failed', | ||
statusText: `your Teleport role's "request.kubernetes_resources" field did not allow requesting to some or all of the requested Kubernetes resources. allowed kinds for each requestable roles: test-role-1: [deployment]`, |
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.
statusText: `your Teleport role's "request.kubernetes_resources" field did not allow requesting to some or all of the requested Kubernetes resources. allowed kinds for each requestable roles: test-role-1: [deployment]`, | |
statusText: `your Teleport role's "request.kubernetes_resources" field did not allow requesting to some or all of the requested Kubernetes resources. Allowed kinds for each requestable roles: test-role-1: [deployment]`, |
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.
this is a backend error and i was told in one of my backend PRs that error messages are not capitalized...
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 had to remove the required checking b/c theres now no clear way to tell if it's required or not.
eg: one role can enforce namespaces only, another role can enforce pods only. it'll be confusing to assume that all kube_cluster resources selected has access to namespaces and mark it required
(letting user try to create request and backend return an error is better)
0bea852
to
81d06e9
Compare
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.
lgtm.
@@ -144,7 +143,7 @@ export function KubeNamespaceSelector({ | |||
return ( | |||
<Box width="100%" mb={-3}> | |||
<StyledSelect | |||
label={`Namespaces${namespaceRequired ? ' (required)' : ''}:`} | |||
label={`Namespaces:`} |
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.
nit: is :
necessary?
* Parses error messsage (in an expected format) to see if | ||
* in the message it's a type of request.kubernetes_resources | ||
* related error, then check if namespace or kube_cluster is mentioned | ||
* in the "allowed kinds" portion of the error message. |
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.
* Parses error messsage (in an expected format) to see if | |
* in the message it's a type of request.kubernetes_resources | |
* related error, then check if namespace or kube_cluster is mentioned | |
* in the "allowed kinds" portion of the error message. | |
* Parses error message (in an expected format returned from the backend) to see if | |
* the message is a type of request.kubernetes_resources (link backend code or add error sample below) related error. | |
* If error matches, it then checks if namespace or kube_cluster is mentioned | |
* in the "allowed kinds" portion of the error message. |
if ( | ||
errMsg.includes('request.kubernetes_resources') && | ||
errMsg.includes('allowed kinds') | ||
) { | ||
let splitMsgParts = []; | ||
if (errMsg.includes('requested roles: ')) { | ||
splitMsgParts = errMsg.split('requested roles: '); | ||
} else if (errMsg.includes('requestable roles: ')) { | ||
splitMsgParts = errMsg.split('requestable roles: '); |
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.
This is really brutal way to guess error type. Not suggesting we change anything here but someday, we should come up with error codes that can be meaningfully shared amongst backend and frontend.
81d06e9
to
b24b5fa
Compare
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 started reviewing this on Thursday but then I got distracted with something else. 🫥
@@ -316,14 +315,14 @@ export function RequestCheckout<T extends PendingListItem>({ | |||
> | |||
tsh request search | |||
</ExternalLink>{' '} | |||
command that will help you construct the request. |
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 think it should still say "command" no?
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.
oh what the.... i have minor UX's stuff i need to address, so i'll add it back
…errors (#48168) * WebShared: Update how request checkout handles kube resource related errors * Fix bug where after create/cancel, specifiable fields were retained * Remove single toggler for kube resources * Address CR
…ces during access requests (#48413) * Web: add support for requesting for kube namespaces (#47345) * Teleterm: add support for access requesting kube namespaces (#47347) * WebShared: Update how request checkout handles kube resource related errors (#48168) * WebShared: Update how request checkout handles kube resource related errors * Fix bug where after create/cancel, specifiable fields were retained * Remove single toggler for kube resources * Address CR * Update snaps * Backport fixes - teleport version v16 and less uses react select version 3 which required to add manual support for initially fetching namespaces on select dropdown - hover tooltip design diffs - field select design diffs
part of #46742
The backend error messaging has changed, so this PR just updates how the web UI processes that error.
It also fixes a subtle bug where, after a request was created (or when user cancels the request), the specifiable fields (eg: suggested reviewers and especially the selected resource roles) were retained, so when user tries to create a new checkout, the
resource roles
fetch can fail, and the followingdry run
fetch referred to the previous requests values of selected roles, which resulted in incorrect error message referring to the wrong roles.Screenshots:
with tooltip, if the error message gets long (happens with wildcard expanded into all kinds supported):
without tooltip (reasonably short error message)