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

Adding grpc_cluster client and server middleware #640

Merged
merged 8 commits into from
Jan 28, 2025

Conversation

duricanikolic
Copy link
Contributor

What this PR does:
This PR introduces 2 gRPC middlewares:

  • A client middleware of type grpc.UnaryClientInterceptor, that propagates a given cluster info to the outgoing gRPC metadata.
  • A server middleware of type grpc.UnaryServerInterceptor, that checks if the incoming gRPC metadata contain any cluster information and if so, checks if the latter corresponds to the given cluster info. If it is the case, the request is further propagated. Otherwise, an error is returned.

Which issue(s) this PR fixes:

Fixes #

Checklist

  • Tests updated
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

Signed-off-by: Yuri Nikolic <durica.nikolic@grafana.com>
@duricanikolic duricanikolic self-assigned this Jan 28, 2025
Signed-off-by: Yuri Nikolic <durica.nikolic@grafana.com>
Signed-off-by: Yuri Nikolic <durica.nikolic@grafana.com>
Signed-off-by: Yuri Nikolic <durica.nikolic@grafana.com>
Copy link
Collaborator

@aknuds1 aknuds1 left a comment

Choose a reason for hiding this comment

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

Generally LGTM, but please see comments.

middleware/grpc_cluster.go Outdated Show resolved Hide resolved
middleware/grpc_cluster.go Outdated Show resolved Hide resolved
middleware/grpc_cluster_test.go Show resolved Hide resolved
middleware/grpc_cluster_test.go Show resolved Hide resolved
Signed-off-by: Yuri Nikolic <durica.nikolic@grafana.com>
@duricanikolic duricanikolic requested a review from aknuds1 January 28, 2025 14:45
Copy link
Collaborator

@aknuds1 aknuds1 left a comment

Choose a reason for hiding this comment

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

I find the handling of empty and not defined cluster metadata unnecessarily complicated, I think the two cases can be handled as the same. WDYT?

middleware/grpc_cluster.go Outdated Show resolved Hide resolved
middleware/grpc_cluster.go Outdated Show resolved Hide resolved
Signed-off-by: Yuri Nikolic <durica.nikolic@grafana.com>
@duricanikolic duricanikolic requested a review from aknuds1 January 28, 2025 15:53
Copy link
Collaborator

@aknuds1 aknuds1 left a comment

Choose a reason for hiding this comment

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

Mostly fine, but there's an extra if left behind.

middleware/grpc_cluster.go Outdated Show resolved Hide resolved
middleware/grpc_cluster_test.go Outdated Show resolved Hide resolved
middleware/grpc_cluster_test.go Outdated Show resolved Hide resolved
middleware/grpc_cluster_test.go Outdated Show resolved Hide resolved
middleware/grpc_cluster_test.go Outdated Show resolved Hide resolved
Signed-off-by: Yuri Nikolic <durica.nikolic@grafana.com>
Copy link
Collaborator

@aknuds1 aknuds1 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@duricanikolic duricanikolic merged commit 555abad into main Jan 28, 2025
5 checks passed
@duricanikolic duricanikolic deleted the yuri/grpc-cluster branch January 28, 2025 21:58
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.

2 participants