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

ClustersClientsPool Middleware #1627

Merged
merged 40 commits into from
Mar 16, 2022
Merged

ClustersClientsPool Middleware #1627

merged 40 commits into from
Mar 16, 2022

Conversation

luizbafilho
Copy link
Contributor

@luizbafilho luizbafilho commented Mar 7, 2022

Closes: #1600

What changed?

Why?

How did you test it?

  • Manually and Unit tests

Release notes

Documentation Changes

@luizbafilho luizbafilho changed the base branch from main to v2 March 7, 2022 16:15
@luizbafilho luizbafilho changed the title Lf/k8s clients pool ClustersClientsPool Middleware Mar 14, 2022
@luizbafilho luizbafilho marked this pull request as ready for review March 14, 2022 17:19
Copy link
Contributor

@jpellizzari jpellizzari left a comment

Choose a reason for hiding this comment

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

Code looks good, but one more cluster field could really move the whole initiative along.

if err != nil {
return nil, fmt.Errorf("converting items: %w", err)
//TODO: handle failures and parallelize
for _, c := range clientsPool.Clients() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a clusterName field to the response payload? The UI will need that to show the name of the cluster in the table.

I think it will need to be an argument to the types.KustomizationToProto function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Given this work is focused on a single cluster, I'll leave this to later because adding these names is nontrivial since we'll have to change the response format and update the UI to comply with it.

pkg/server/auth/server.go Outdated Show resolved Hide resolved
core/multicluster/middleware.go Outdated Show resolved Hide resolved
core/multicluster/multicluster.go Outdated Show resolved Hide resolved
@luizbafilho luizbafilho changed the base branch from v2 to main March 16, 2022 13:57
@luizbafilho luizbafilho force-pushed the lf/k8s-clients-pool branch from 9c05af5 to 6512b46 Compare March 16, 2022 13:59
@luizbafilho luizbafilho added the type/enhancement New feature or request label Mar 16, 2022
Copy link
Contributor

@Callisto13 Callisto13 left a comment

Choose a reason for hiding this comment

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

looks good, just a couple of idle thoughts

core/clustersmngr/middleware_test.go Outdated Show resolved Hide resolved
core/clustersmngr/single_fetcher.go Outdated Show resolved Hide resolved
pkg/server/handler.go Outdated Show resolved Hide resolved
return
}

clusters, err := clustersFetcher.Fetch(r.Context())
Copy link
Contributor

Choose a reason for hiding this comment

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

we are punting the caching of the available clusters to another PR right?

tho i suppose the implementor of the interface can cache on that side. actually that is the better idea, nvm!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep, not handling any of that now.

@@ -74,3 +76,23 @@ func makeGRPCServer(cfg *rest.Config, t *testing.T) pb.CoreClient {

return pb.NewCoreClient(conn)
}

func withClientsPoolInterceptor(config *rest.Config, user *auth.UserPrincipal) grpc.ServerOption {
return grpc.UnaryInterceptor(func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we sure this runs? I have run into issues before where the middlewares don't run with our current implementation: grpc-ecosystem/grpc-gateway#1043

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, if we comment that out the test breaks because the clients pool doesnt get injected

Copy link
Contributor

Choose a reason for hiding this comment

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

What about when the server is actually running?

Copy link
Contributor Author

@luizbafilho luizbafilho Mar 16, 2022

Choose a reason for hiding this comment

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

I don't know, if you pay attention to that's for test only since we use HTTP middleware for it.

@luizbafilho luizbafilho requested a review from Callisto13 March 16, 2022 16:02
Copy link
Contributor

@Callisto13 Callisto13 left a comment

Choose a reason for hiding this comment

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

:shipit:

@luizbafilho luizbafilho merged commit e212a79 into main Mar 16, 2022
@luizbafilho luizbafilho deleted the lf/k8s-clients-pool branch March 16, 2022 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement ClustersClientsMiddleware
3 participants