Do not send "assume role" usage event when dropping access request#42533
Merged
Do not send "assume role" usage event when dropping access request#42533
Conversation
Each call is wrapped in `retryWithRelogin` in UI and `clusters.AddMetadataToRetryableError` in tshd. If the cluster is not connected, we should ask the user to log in, rather than fail silently.
avatus
approved these changes
Jun 7, 2024
ravicious
approved these changes
Jun 10, 2024
| rootClusterUri, | ||
| accessRequestId: requestId, | ||
| }); | ||
| }) |
Member
There was a problem hiding this comment.
const [deleteRequestAttempt, runDeleteRequest] = useAsync(() =>
retry(() =>
ctx.tshd.deleteAccessRequest({
rootClusterUri,
accessRequestId: requestId,
})
)
);web/packages/teleterm/src/ui/DocumentAccessRequests/ReviewAccessRequest/useReviewAccessRequest.ts:74:7 - error TS2739: Type 'CloneableUnaryCall<DeleteAccessRequestRequest, EmptyResponse>' is missing the following properties from type 'Promise<FinishedUnaryCall<DeleteAccessRequestRequest, EmptyResponse>>': catch, finally, [Symbol.toStringTag]
74 ctx.tshd.deleteAccessRequest({
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
75 rootClusterUri,
~~~~~~~~~~~~~~~~~~~~~~~
76 accessRequestId: requestId,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
77 })
~~~~~~~~
web/packages/teleterm/src/ui/DocumentAccessRequests/ReviewAccessRequest/useReviewAccessRequest.ts:55:17
55 <T>(action: () => Promise<T>) => retryWithRelogin(ctx, clusterUri, action),
~~~~~~~~~~~~~~~~
The expected type comes from the return type of this signature.
I guess we forgot to implement catch and finally on the cloneable client? 😩 Or just maybe it's a matter of adding relevant types. This whole time I've assumed they were implemented in terms of then. 🤷
Anyway, it's something we should tackle down the road.
Contributor
Author
There was a problem hiding this comment.
No, we didn't not forget.
protobuf-ts type exposes only .then - this concept is called thenable https://masteringjs.io/tutorials/fundamentals/thenable.
To simplify this call we could remove await:
const [deleteRequestAttempt, runDeleteRequest] = useAsync(() =>
retry(async () =>
ctx.tshd.deleteAccessRequest({
rootClusterUri,
accessRequestId: requestId,
})
)
);but I wanted the attempt to be of type Attempt<void>, since we are not interested in the response anyway.
This was referenced Jun 10, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #42484
To fix the issue, I separated methods for assuming and dropping requests. We never assume and drop a request at the same time, so I think this change will make this API easier to use. Let me know what you think about it.
While I was there, I also removed
cluster.connectchecks. Each of these calls is wrapped inretryWithReloginin UI andclusters.AddMetadataToRetryableErrorin tshd.If the cluster is not connected, we should ask the user to log in, rather than fail silently.
After that I removed some methods completely, as they only passed calls to
tshd.