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

Remove usage of deprecated grpc-go methods #5725

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

rturner3
Copy link
Collaborator

Replace usage of deprecated grpc.Dial()/grpc.DialContext() methods with grpc.NewClient(). Also remove usage of grpc.WithBlock(), grpc.FailOnNonTempDialError(), and grpc.WithReturnConnectionError() options.

The combination of these changes results in a couple behavioral changes when setting up gRPC clients:

  1. gRPC will no longer dial when creating the client. Instead, it will wait until the client is used for the first time with an RPC invocation.

  2. gRPC uses the DNS resolver by default when building the *grpc.ClientConn using grpc.NewClient(), whereas previously it used to resolve addresses the passthrough resolver by default. The result of this change in behavior is that for any invocations of grpc.Dial()/grpc.DialContext() that did not specify a URI scheme, gRPC now implicitly tries to resolve the address passed to grpc.NewClient() using DNS. This breaks some assumptions in the code. The workaround to preserve the previous address resolution behavior is to prepend addresses with no scheme defined with the resolver URI scheme passthrough:.

Also refactored some test-related code in cmd/spire-server/cli/common into a new test/clitest package, since it is not intended for use in production code.

Fixes #5152.

Replace usage of deprecated `grpc.Dial()`/`grpc.DialContext()` methods
with `grpc.NewClient()`. Also remove usage of `grpc.WithBlock()`,
`grpc.FailOnNonTempDialError()`, and `grpc.WithReturnConnectionError()`
options.

The combination of these changes results in a couple behavioral changes
when setting up gRPC clients:

1. gRPC will no longer dial when creating the client. Instead, it will
wait until the client is used for the first time with an RPC invocation.

2. gRPC uses the DNS resolver by default when building the
`*grpc.ClientConn` using `grpc.NewClient()`, whereas previously it used
to resolve addresses the `passthrough` resolver by default. The result
of this change in behavior is that for any invocations of
`grpc.Dial()`/`grpc.DialContext()` that did not specify a URI scheme,
gRPC now implicitly tries to resolve the address passed to
`grpc.NewClient()` using DNS. This breaks some assumptions in the code.
The workaround to preserve the previous address resolution behavior is
to prepend addresses with no scheme defined with the resolver URI scheme
`passthrough:`.

Also refactored some test-related code in `cmd/spire-server/cli/common`
into a new `test/clitest` package, since it is not intended
for use in production code.

Fixes spiffe#5152.

Signed-off-by: Ryan Turner <[email protected]>
Signed-off-by: Ryan Turner <[email protected]>
@rturner3 rturner3 marked this pull request as draft December 17, 2024 07:55
@rturner3 rturner3 marked this pull request as ready for review December 18, 2024 04:19
@MarcosDY MarcosDY self-assigned this Dec 19, 2024
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.

Do not use grpc.Dial and deprecated DialOptions
2 participants