Skip to content
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

Merged
merged 4 commits into from
Nov 1, 2024

Conversation

kimlisa
Copy link
Contributor

@kimlisa kimlisa commented Oct 30, 2024

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 following dry 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):
image

without tooltip (reasonably short error message)
image

Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-48168.d3pp5qlev8mo18.amplifyapp.com

@kimlisa kimlisa added no-changelog Indicates that a PR does not require a changelog entry backport/branch/v16 backport/branch/v17 labels Oct 30, 2024
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]`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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]`,

Copy link
Contributor Author

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...

Copy link
Contributor Author

@kimlisa kimlisa Oct 31, 2024

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)

@kimlisa kimlisa force-pushed the lisa/update-web-ui branch 2 times, most recently from 0bea852 to 81d06e9 Compare October 31, 2024 04:54
Copy link
Contributor

@flyinghermit flyinghermit left a 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:`}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: is : necessary?

Comment on lines 48 to 51
* 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* 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.

Comment on lines +65 to +71
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: ');
Copy link
Contributor

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.

@kimlisa kimlisa added this pull request to the merge queue Nov 1, 2024
Merged via the queue into master with commit 3491836 Nov 1, 2024
39 checks passed
@kimlisa kimlisa deleted the lisa/update-web-ui branch November 1, 2024 05:24
@public-teleport-github-review-bot

@kimlisa See the table below for backport results.

Branch Result
branch/v16 Failed
branch/v17 Create PR

Copy link
Member

@ravicious ravicious left a 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.
Copy link
Member

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?

Copy link
Contributor Author

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

kimlisa added a commit that referenced this pull request Nov 5, 2024
…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
github-merge-queue bot pushed a commit that referenced this pull request Nov 5, 2024
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/branch/v16 backport/branch/v17 no-changelog Indicates that a PR does not require a changelog entry size/md ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants