Skip to content

Add GetServers parameterized search for Connect grpc#15934

Closed
avatus wants to merge 24 commits intomasterfrom
michaelmyers/connect/add-parameter-search
Closed

Add GetServers parameterized search for Connect grpc#15934
avatus wants to merge 24 commits intomasterfrom
michaelmyers/connect/add-parameter-search

Conversation

@avatus
Copy link
Copy Markdown
Contributor

@avatus avatus commented Aug 30, 2022

This PR will change Connect's grpc endpoint of ListServers to two different endpoints, GetAllServers and GetServers.

  1. GetAllServers functions the same way as ListServers did and is just a name change. The reason we need to keep this functionality is that it will pull ALL servers at cluster init (in chunks of 1000). It calls the same thing as tsh/tctl here. We shouldn't add pagination and sorting to this endpoint, especially since the web server already has it.
  2. GetServers replicates the functionality of the web ui's server side pagination eventually calling ListResources . This is how we will do server side pagination/sorting/searching (including advanced) search. For now, Connect will only use this endpoint during access requests.

I left a comment around getting the authClient for ListResources and will remove it before merging but wanted to leave it marked for feedback. Was trying to access the same thing as clt found here in the webui, although I'm a bit unsure if thats the best. hacked around on that part tbh.

webapps related PR here

Comment thread lib/teleterm/clusters/cluster_servers.go Outdated
Comment thread lib/teleterm/clusters/cluster_servers.go
Comment thread lib/teleterm/clusters/cluster_servers.go Outdated
Comment thread lib/teleterm/daemon/daemon.go Outdated
Comment thread lib/teleterm/daemon/daemon.go Outdated
Copy link
Copy Markdown
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.

The overall approach looks fine, I left some comments regarding the details of the implementation.

Perhaps the most important thing is preparing the accompanying webapps PR which updates the protos on the frontend.

Comment thread lib/teleterm/clusters/cluster_servers.go Outdated
Comment thread lib/teleterm/clusters/cluster_servers.go Outdated
Comment thread lib/teleterm/clusters/cluster_servers.go Outdated
Comment thread lib/teleterm/api/protogen/js/v1/service_grpc_pb.d.ts
Comment thread lib/teleterm/daemon/daemon.go Outdated
Comment thread lib/teleterm/api/proto/v1/service.proto Outdated
Comment thread lib/teleterm/clusters/cluster_servers.go Outdated
Comment thread lib/teleterm/clusters/cluster_servers.go Outdated
Comment thread lib/teleterm/clusters/cluster_servers.go
Comment thread lib/teleterm/clusters/cluster_servers.go
Copy link
Copy Markdown
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.

Looks fine but I'd strongly suggest refactoring that web server part to use the new function and adding some tests. Leaving a preemptive approve since I might not have time to look at the PR again before I'm off.

Comment thread lib/teleterm/clusters/cluster_servers.go Outdated
Comment thread api/types/sortby.go Outdated
Comment thread api/types/sortby.go Outdated
Copy link
Copy Markdown
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.

Looks stellar now, good job.

Comment thread api/types/sortby.go Outdated
Comment thread api/types/sortby.go Outdated
// index 0 is fieldName and index 1 is direction.
// If a direction is not set, or is not recognized, it defaults to ASC.
func GetSortByFromString(sortStr string) (sortBy SortBy) {
if sortStr != "" {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I would invert this check, so that most of the code is left-aligned:

if sortStr == "" {
    return sortBy
}
vals := strings.Split(...
...

Comment thread api/types/sortby.go
@@ -0,0 +1,22 @@
package types
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is types the best package for this? This is a pretty low-level commonly imported package. Maybe there's a better place for it?

Copy link
Copy Markdown
Contributor Author

@avatus avatus Sep 2, 2022

Choose a reason for hiding this comment

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

This was our first best guess at where to put it. I'm open to suggestions, not quite sure which context suites it best.

Comment thread api/types/sortby_test.go Outdated
Comment thread lib/teleterm/clusters/cluster_servers.go Outdated
Comment thread lib/teleterm/daemon/daemon.go
@avatus
Copy link
Copy Markdown
Contributor Author

avatus commented Sep 22, 2022

Closing this because the changes are coming in my larger PR for Connect access requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants