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

Upgrade GRPC version due to new feature introduced in 1.40.0 version. #583

Merged
merged 6 commits into from Sep 24, 2021

Conversation

luankevinferreira
Copy link
Contributor

When I'm using the following plugin with grpc-spring-boot-starter and try to use the 1.40.1 version of grpc-java, an error occurs as mentioned in this issue grpc/grpc-java#8523.

                         <plugin>
				<groupId>org.xolstice.maven.plugins</groupId>
				<artifactId>protobuf-maven-plugin</artifactId>
				<version>${protobuf-maven-plugin.version}</version>
				<configuration>
					<protocArtifact>
						com.google.protobuf:protoc:3.17.3:exe:${os.detected.classifier}
					</protocArtifact>
					<pluginId>grpc-java</pluginId>
					<pluginArtifact>
						io.grpc:protoc-gen-grpc-java:1.40.1:exe:${os.detected.classifier}
					</pluginArtifact>
				</configuration>
				<executions>
					<execution>
						<goals>
							<goal>compile</goal>
							<goal>compile-custom</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

ST-DDT
ST-DDT previously approved these changes Sep 14, 2021
Copy link
Collaborator

@ST-DDT ST-DDT 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 to me. Thanks for your contribution.

@ST-DDT
Copy link
Collaborator

ST-DDT commented Sep 14, 2021

Please note that you can overwrite the dependency versions using the grpc-bom.
I use this library 2.12 along with grpc 1.40 without any issues.

@ST-DDT
Copy link
Collaborator

ST-DDT commented Sep 18, 2021

@luankevinferreira Could you please check why the tests are failing?
Or should I take over from this point?

@ST-DDT ST-DDT added enhancement A feature request or improvement feedback required Information are missing or feedback for suggestions is requested labels Sep 18, 2021
@ST-DDT ST-DDT added this to the 2.13.0 milestone Sep 18, 2021
@luankevinferreira
Copy link
Contributor Author

@ST-DDT I've looked at the logs and seemed to be some temporary failure with host name resolution, I've updated the branch and now is requiring an approval of the workflow to be run, could you please approve?

@ST-DDT
Copy link
Collaborator

ST-DDT commented Sep 19, 2021

SelfNameResolverConnectionTest > testSelfConnection() FAILED
    io.grpc.StatusRuntimeException: UNAVAILABLE: Unable to resolve host self
        at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:262)
        at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:243)
        at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:156)
        at net.devh.boot.grpc.test.proto.TestServiceGrpc$TestServiceBlockingStub.normal(TestServiceGrpc.java:579)
        at net.devh.boot.grpc.test.setup.SelfNameResolverConnectionTest.testSelfConnection(SelfNameResolverConnectionTest.java:62)

        Caused by:
        java.lang.RuntimeException: java.net.UnknownHostException: self
            at io.grpc.internal.DnsNameResolver.resolveAddresses(DnsNameResolver.java:223)
            at io.grpc.internal.DnsNameResolver.doResolve(DnsNameResolver.java:282)
            at io.grpc.internal.DnsNameResolver$Resolve.run(DnsNameResolver.java:318)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
            at java.lang.Thread.run(Thread.java:748)

            Caused by:
            java.net.UnknownHostException: self
                at java.net.InetAddress.getAllByName0(InetAddress.java:1281)
                at java.net.InetAddress.getAllByName(InetAddress.java:1193)
                at java.net.InetAddress.getAllByName(InetAddress.java:1127)
                at io.grpc.internal.DnsNameResolver$JdkAddressResolver.resolveAddress(DnsNameResolver.java:631)
                at io.grpc.internal.DnsNameResolver.resolveAddresses(DnsNameResolver.java:219)
                ... 5 more

AFAICT the SelfNameResolver does not work as expected anymore.

@luankevinferreira
Copy link
Contributor Author

@ST-DDT does this error was caused by the change of version or is something internally?

@ST-DDT
Copy link
Collaborator

ST-DDT commented Sep 21, 2021

This failure is related to the change in grpc version, although I'm not sure why.
From a technical perspective the code should not attempt the DnsNameResolver and instead use the SelfResolver.
I assume this is related to the NameResolverRegistry bean (either not working or being a copy instead of a reference).
Alternatively, there was a change regarding missing schemes in the address urls.

@ST-DDT
Copy link
Collaborator

ST-DDT commented Sep 21, 2021

I checked the respective code and found grpc/grpc-java#8323 to be responsible for the breakage.
But I also found:

/**
     * Creates a {@link NameResolver} for the given target URI, or {@code null} if the given URI
     * cannot be resolved by this factory. The decision should be solely based on the scheme of the
     * URI.
     *
     * @param targetUri the target URI to be resolved, whose scheme must not be {@code null}
     * @param args other information that may be useful
     *
     * @since 1.21.0
     */

The SelfNameResolverFactory does not abide by this rule and also uses the full uri, thus being an invalid implementation.

    public NameResolver newNameResolver(final URI targetUri, final Args args) {
        if (SELF_SCHEME.equals(targetUri.getScheme()) || targetUri.toString().equals(SELF_SCHEME)) {
            return new SelfNameResolver(this.properties, args);
        }
        return null;
    }

The following needs to be done to fix this:

  • Edit SelfNameResolverFactory to only use the scheme
  • Search for all tests that use the client name self or use self as address and set their address to self:self (or similar)
  • Search and update the documentation for hints regarding name resolution

@luankevinferreira Would you like to give it a try?

@luankevinferreira
Copy link
Contributor Author

@ST-DDT I did some changes, could you please approve the workflow and review if is everything ok?

Copy link
Collaborator

@ST-DDT ST-DDT left a comment

Choose a reason for hiding this comment

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

The original test was intended to test both name based logic and address based lookup.
Now that the name based resolution is no longer be possible we can simplify it to one test.

Copy link
Collaborator

@ST-DDT ST-DDT left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution!

@ST-DDT ST-DDT merged commit c666b01 into grpc-ecosystem:master Sep 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A feature request or improvement feedback required Information are missing or feedback for suggestions is requested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants