-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Teleterm: add support for access requesting kube namespaces #47347
base: lisa/kube-namespace-3
Are you sure you want to change the base?
Conversation
The PR changelog entry failed validation: Changelog entry not found in the PR body. Please add a "no-changelog" label to the PR, or changelog lines starting with |
The PR changelog entry failed validation: Changelog entry not found in the PR body. Please add a "no-changelog" label to the PR, or changelog lines starting with |
768b594
to
3140a5c
Compare
357f75a
to
65cb297
Compare
web/packages/teleterm/src/ui/AccessRequestCheckout/AccessRequestCheckout.tsx
Outdated
Show resolved
Hide resolved
web/packages/teleterm/src/ui/AccessRequestCheckout/AccessRequestCheckout.tsx
Outdated
Show resolved
Hide resolved
web/packages/teleterm/src/ui/services/workspacesService/accessRequestsService.ts
Outdated
Show resolved
Hide resolved
web/packages/teleterm/src/ui/AccessRequestCheckout/useAccessRequestCheckout.ts
Outdated
Show resolved
Hide resolved
3140a5c
to
a7f49c2
Compare
65cb297
to
2042699
Compare
web/packages/teleterm/src/ui/AccessRequestCheckout/useAccessRequestCheckout.ts
Show resolved
Hide resolved
web/packages/teleterm/src/ui/services/workspacesService/accessRequestsService.ts
Outdated
Show resolved
Hide resolved
web/packages/teleterm/src/ui/services/workspacesService/accessRequestsService.ts
Outdated
Show resolved
Hide resolved
web/packages/teleterm/src/ui/AccessRequestCheckout/useAccessRequestCheckout.ts
Outdated
Show resolved
Hide resolved
@@ -337,7 +447,9 @@ export default function useAccessRequestCheckout() { | |||
isCollapsed, | |||
assumedRequests: getAssumedRequests(), | |||
toggleResource, | |||
data: getPendingAccessRequestsPerResource(pendingAccessRequest), | |||
data: getPendingAccessRequestsPerResource({ |
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.
In a similar vein to getPendingAccessRequestsPerResource
, I think data
needs to be rethought as well.
"Data" in itself is a super vague name. That'd be the most important thing, to find a name for it that better describes what data
is.
When data
is consumed in web/packages/teleterm/src/ui/AccessRequestCheckout/AccessRequestCheckout.tsx
, it's usually filtered in different ways and the result is called filteredData
, which is also pretty vague. Then we pass filteredData
to some places and data
to other. data
is then filtered again.
As I understand, this is because sometimes we want to show items with kube clusters present and sometimes we want to ignore them and use only namespaces.
I think it'd be highly beneficial to find better names than data
and filteredData
which better describe in what scenarios certain values are used. Even better, once that is done, we can have separate types for them – this way we'll never pass kube_cluster
items to places where they're not expected (think Exclude<Data, {kind: 'kube_cluster'}>
.
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 (hope) i resolved this with rename here: #47722
2042699
to
6902cd8
Compare
@@ -87,9 +94,18 @@ export default function useAccessRequestCheckout() { | |||
const workspaceAccessRequest = | |||
ctx.workspacesService.getActiveWorkspaceAccessRequestsService(); | |||
const docService = ctx.workspacesService.getActiveWorkspaceDocumentService(); | |||
const pendingAccessRequest = | |||
const pendingAccessRequestRequest = |
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 not sure about RequestRequest
🙈 Maybe workspaceAccessRequest
?
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.
workspaceAccessRequest
already exists in line 94
/** | ||
* | ||
* @param pendingRequest holds a list or map of resources to process | ||
* @param excludeSubResourceParentResource when true, resources that have |
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.
excludeSubResourceParentResource
doesn't exist.
.map(d => { | ||
if (d.kind === 'namespace') { | ||
return { | ||
name: d.id, | ||
kind: d.kind, | ||
clusterName: d.clusterName, | ||
subResourceName: d.subResourceName, | ||
}; | ||
} | ||
return { | ||
name: d.id, | ||
clusterName: d.clusterName, | ||
kind: d.kind, | ||
subResourceName: '', | ||
}; | ||
}), |
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.
.map(d => { | |
if (d.kind === 'namespace') { | |
return { | |
name: d.id, | |
kind: d.kind, | |
clusterName: d.clusterName, | |
subResourceName: d.subResourceName, | |
}; | |
} | |
return { | |
name: d.id, | |
clusterName: d.clusterName, | |
kind: d.kind, | |
subResourceName: '', | |
}; | |
}), | |
.map(d => ({ | |
name: d.id, | |
clusterName: d.clusterName, | |
kind: d.kind, | |
subResourceName: d.subResourceName || '', | |
})), |
@@ -268,6 +352,7 @@ export default function useAccessRequestCheckout() { | |||
}); | |||
teletermAccessRequest = accessRequest; | |||
} catch { | |||
setCreateRequestAttempt({ status: '' }); |
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.
Shouldn't this be an error state?
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.
no b/c dry run
is not a create request
. i think i ran into an issue where, create
resulted in an error, so the user modifies the checked out items which would trigger dry run
again (so we are resetting here)
i moved it out to the top, since i realized we are clearing it on error and on success
@@ -64,3 +67,120 @@ test('fetching requestable roles for servers uses UUID, not hostname', async () | |||
}) | |||
); | |||
}); | |||
|
|||
test('fetching requestable roles kube_cluster resource without namespace request', async () => { |
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's more readable:
test('fetching requestable roles kube_cluster resource without namespace request', async () => { | |
test('fetching requestable roles for a kube_cluster resource without specifying a namespace', async () => { |
I'll take a look tomorrow and I'll try to use the UI. |
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.
When I want to remove the labels by clicking the ❎ button next to each label, the list keeps opening, requiring me to click twice if I want to remove a bunch of labels consecutively.
removing-namespaces.mov
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.
punted to this issue: #47823
the selector got kinda wonky after upgrade (i also previously supported bulk deleter too but removed it b/c it was too buggy)
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.
idk how to create a minimal repro for this, but sometimes after closing the select, the list of selected namespaces gets sorted. In the video it happens right at the end.
Is it because we sort it at some point or is it because the namespaces are kept in a set in Connect? FWIW, I think Set in JS keeps insertion order, so idk if it's plausible for this data structure to cause that.
sort-after-select-close.mov
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 doesn't look like sorting, but just rearranging? maybe it's b/c of how we bulk toggle
@@ -211,6 +211,12 @@ export default function useNewRequest(rootCluster: Cluster) { | |||
return; | |||
} | |||
|
|||
if (kind === 'namespace') { | |||
// It is not possible to request a kube namespace through this function. | |||
// The type should be corrected. |
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.
Is it actually possible to adjust the type? I don't think so, as AFAIK we can't just remove namespace
from ResourceKind
. I'm not sure how much sense would it make to use Exclude<ResourceKind, 'namespace'>
in this particular example.
Perhaps it'd be best to add a comment to addOrRemoveResource
explaining that it's used for adding individual resources from the unified resources view and then this comment here could simply say that it's impossible to add kube namespaces straight from the unified resources view, so this function returns early?
7b9a051
to
638a391
Compare
This reverts commit 97c080d55fac335db0545440c7a05551ceffae87.
1e15bef
to
939680d
Compare
939680d
to
c7802cb
Compare
part of #46742
requires:
role.options
field calledrequest_mode.kubernetes_resources
#47173if you want to test connect, i have a staging cluster that i can invite you to (dm me) then:
when request mode requires you to request for namespace
when request mode is a kind that UI doesn't support, it disables the checkout regardless of other resources (it is enabled once user removes the kubernetes):
demo (when no request mode is specified, allows requesting for a
kube_cluster
or akube_clusters
namespace):Screen.Recording.2024-10-08.at.11.58.11.PM.mov
changelog: Add Connect support for selecting Kubernetes namespaces during access requests