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

gRPC Services error when running mutiny API and default gRPC API #44326

Open
jjpinto opened this issue Nov 5, 2024 · 15 comments
Open

gRPC Services error when running mutiny API and default gRPC API #44326

jjpinto opened this issue Nov 5, 2024 · 15 comments
Labels

Comments

@jjpinto
Copy link

jjpinto commented Nov 5, 2024

Describe the bug

When using the same .proto file for both a class implementing the Mutiny API and another class using the default gRPC API in Quarkus, only the service implemented with the default API appears in the gRPC services list.

The service using the Mutiny API gets removed and is not available. However, if I create a separate .proto file and use it for one of the implementations, both services show up in the Dev UI under gRPC services.

Expected behavior

I expected both services to be available for connection and visible in the Dev UI under gRPC services. It should not matter if they are using the same .proto file.

Actual behavior

Using the grpc-plain-text-quickstart, I created a class using the default api example from the documentation. When testing both the default API and mutiny API, I realized that one endpoint was missing. The default API displays in the gRPC · Services, however the mutiny api got removed. I found it in the ARC - removed components (dev-ui) and they are also not available when I call it.

How to Reproduce?

Get the grpc-plain-test-quickstart
Add a class to io.quarkus.grpc.examples.hello;
use the extends GreeterImplBase

insert the code
@OverRide
public void sayHello(HelloRequest request, StreamObserver responseObserver) {
String name = request.getName();
HelloReply reply = HelloReply.newBuilder().setMessage("Hello " +
name).build();
responseObserver.onNext(reply);
responseObserver.onCompleted();
}

compile and run quarkus:dev

Output of uname -a or ver

Linux L91PLPG3 5.10.16.3-microsoft-standard-WSL2 #1 SMP Fri Apr 2 22:23:49 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

openjdk version "22.0.1" 2024-04-16

Quarkus version or git rev

3.16.1

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.9.5 (57804ffe001d7215b5e7bcb531cf83df38f93546)

Additional information

No response

@jjpinto jjpinto added the kind/bug Something isn't working label Nov 5, 2024
Copy link

quarkus-bot bot commented Nov 5, 2024

/cc @alesj (grpc), @cescoffier (grpc,mutiny), @jponge (mutiny)

@cescoffier
Copy link
Member

I thin it's expected. You cannot have 2 implementations of the same service.

Now we should fails the build in this case.

@jjpinto
Copy link
Author

jjpinto commented Nov 5, 2024

I agree that failing the build or providing a clear error message indicating the conflict would be beneficial. This would help others like me to identify and resolve the issue quickly.

@cescoffier
Copy link
Member

Totally agree!

@alesj WDYT?

@alesj
Copy link
Contributor

alesj commented Nov 14, 2024

I already get this when running this with "mvn clean quarkus:dev"

2024-11-14 09:21:56,109 INFO  [io.qua.grp.run.GrpcServerRecorder] (Quarkus Main Thread) Registering gRPC reflection service
2024-11-14 09:21:56,203 ERROR [io.qua.run.Application] (Quarkus Main Thread) Failed to start application: java.lang.RuntimeException: Failed to start quarkus
	at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source)
	at io.quarkus.runtime.Application.start(Application.java:101)
	at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:121)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:71)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:44)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:124)
	at io.quarkus.runner.GeneratedMain.main(Unknown Source)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at io.quarkus.runner.bootstrap.StartupActionImpl$1.run(StartupActionImpl.java:116)
	at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: java.lang.IllegalStateException: Duplicated gRPC service: helloworld.Greeter
	at io.quarkus.grpc.reflection.service.GrpcServerIndex.<init>(GrpcServerIndex.java:49)
	at io.quarkus.grpc.reflection.service.ReflectionServiceV1.<init>(ReflectionServiceV1.java:32)
	at io.quarkus.grpc.runtime.GrpcServerRecorder.buildServer(GrpcServerRecorder.java:552)
	at io.quarkus.grpc.runtime.GrpcServerRecorder.devModeStart(GrpcServerRecorder.java:299)
	at io.quarkus.grpc.runtime.GrpcServerRecorder.initializeGrpcServer(GrpcServerRecorder.java:130)
	at io.quarkus.deployment.steps.GrpcServerProcessor$initializeServer760746362.deploy_0(Unknown Source)
	at io.quarkus.deployment.steps.GrpcServerProcessor$initializeServer760746362.deploy(Unknown Source)

But I guess this depends if the reflection service is enabled ...

@jjpinto
Copy link
Author

jjpinto commented Nov 14, 2024

@alesj - Could you please add what you have on your application.properties

@jjpinto
Copy link
Author

jjpinto commented Nov 14, 2024

@alesj - I have 2 classes annotated with @GrpcService

@GrpcService
public class GreeterService extends GreeterImplBase {
//implementation details
}
@GrpcService
public class GreeterServiceMutiny implements Greeter {
//implementation details
}
when I compile using "mvn clean quarkus:dev", the build completes successfully, However, in the DEV-UI, it shows that ArC has removed components, specifically indicating thatGreeterServiceMutiny is removed.

** Both ways build fine: With and without data in application.properties
quarkus.grpc.server.port=9090
quarkus.grpc.server.enable-reflection-service=true
quarkus.grpc.server.use-separate-server=false

alesj added a commit to alesj/quarkus that referenced this issue Nov 14, 2024
alesj added a commit to alesj/quarkus that referenced this issue Nov 14, 2024
@alesj
Copy link
Contributor

alesj commented Nov 14, 2024

@alesj - Could you please add what you have on your application.properties

alesj@4eee093

@alesj
Copy link
Contributor

alesj commented Nov 19, 2024

it shows that ArC has removed components, specifically indicating thatGreeterServiceMutiny is removed.

It's not Arc, it's the GrpcServerProcessor::processGeneratedBeans

            // Now derive the original impl base
            // e.g. examples.MutinyGreeterGrpc.GreeterImplBase -> examples.GreeterGrpc.GreeterImplBase
            DotName implBase = DotName.createSimple(mutinyImplBaseName.replace(MutinyGrpcGenerator.CLASS_PREFIX, ""));
            if (!index.getIndex().getAllKnownSubclasses(implBase).isEmpty()) {
                // Some class extends the impl base
                continue;

@alesj
Copy link
Contributor

alesj commented Nov 27, 2024

@cescoffier so the question is, should this fail or at least a warning?

@cescoffier
Copy link
Member

I would say fail. Or do i miss a use case? Only one service will be reachable and we don't know which one :-)

@jjpinto
Copy link
Author

jjpinto commented Nov 27, 2024

Agreed, let's ensure it fails with a clear and reasonable error message :)
btw: @alesj will check your commits later today.

@alesj
Copy link
Contributor

alesj commented Nov 27, 2024 via email

@jjpinto
Copy link
Author

jjpinto commented Nov 28, 2024

I already get this when running this with "mvn clean quarkus:dev"

2024-11-14 09:21:56,109 INFO  [io.qua.grp.run.GrpcServerRecorder] (Quarkus Main Thread) Registering gRPC reflection service
2024-11-14 09:21:56,203 ERROR [io.qua.run.Application] (Quarkus Main Thread) Failed to start application: java.lang.RuntimeException: Failed to start quarkus
	at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source)
	at io.quarkus.runtime.Application.start(Application.java:101)
	at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:121)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:71)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:44)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:124)
	at io.quarkus.runner.GeneratedMain.main(Unknown Source)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at io.quarkus.runner.bootstrap.StartupActionImpl$1.run(StartupActionImpl.java:116)
	at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: java.lang.IllegalStateException: Duplicated gRPC service: helloworld.Greeter
	at io.quarkus.grpc.reflection.service.GrpcServerIndex.<init>(GrpcServerIndex.java:49)
	at io.quarkus.grpc.reflection.service.ReflectionServiceV1.<init>(ReflectionServiceV1.java:32)
	at io.quarkus.grpc.runtime.GrpcServerRecorder.buildServer(GrpcServerRecorder.java:552)
	at io.quarkus.grpc.runtime.GrpcServerRecorder.devModeStart(GrpcServerRecorder.java:299)
	at io.quarkus.grpc.runtime.GrpcServerRecorder.initializeGrpcServer(GrpcServerRecorder.java:130)
	at io.quarkus.deployment.steps.GrpcServerProcessor$initializeServer760746362.deploy_0(Unknown Source)
	at io.quarkus.deployment.steps.GrpcServerProcessor$initializeServer760746362.deploy(Unknown Source)

But I guess this depends if the reflection service is enabled ...

I already get this when running this with "mvn clean quarkus:dev"

2024-11-14 09:21:56,109 INFO  [io.qua.grp.run.GrpcServerRecorder] (Quarkus Main Thread) Registering gRPC reflection service
2024-11-14 09:21:56,203 ERROR [io.qua.run.Application] (Quarkus Main Thread) Failed to start application: java.lang.RuntimeException: Failed to start quarkus
	at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source)
	at io.quarkus.runtime.Application.start(Application.java:101)
	at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:121)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:71)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:44)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:124)
	at io.quarkus.runner.GeneratedMain.main(Unknown Source)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at io.quarkus.runner.bootstrap.StartupActionImpl$1.run(StartupActionImpl.java:116)
	at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: java.lang.IllegalStateException: Duplicated gRPC service: helloworld.Greeter
	at io.quarkus.grpc.reflection.service.GrpcServerIndex.<init>(GrpcServerIndex.java:49)
	at io.quarkus.grpc.reflection.service.ReflectionServiceV1.<init>(ReflectionServiceV1.java:32)
	at io.quarkus.grpc.runtime.GrpcServerRecorder.buildServer(GrpcServerRecorder.java:552)
	at io.quarkus.grpc.runtime.GrpcServerRecorder.devModeStart(GrpcServerRecorder.java:299)
	at io.quarkus.grpc.runtime.GrpcServerRecorder.initializeGrpcServer(GrpcServerRecorder.java:130)
	at io.quarkus.deployment.steps.GrpcServerProcessor$initializeServer760746362.deploy_0(Unknown Source)
	at io.quarkus.deployment.steps.GrpcServerProcessor$initializeServer760746362.deploy(Unknown Source)

But I guess this depends if the reflection service is enabled ...

Thanks for sharing your code @alesj . I was able to download and test it in my environment. Here are a couple of comments:
I'm not entirely sure if reflection is relevant in this example, but it could be a factor. I compared your code with mine and tried a few different approaches. I was able to identify the issue that I encounter but you don't when compiling the project. Essentially, the error does not occur when you have a class without all the RPCs. When you don't include all the RPCs, Quarkus compiles fine! For instance, in your code, if you remove:

@OverRide
public void greeting(LanguageSpec request, StreamObserver responseObserver)

You will be able to compile without any issues.

I hope this helps! Let me know if you need anything else.

@alesj
Copy link
Contributor

alesj commented Nov 28, 2024

Nah, that is not the right code -- I haven't yet made the right fix.
Will do it asap -- away on some Quarkus AI workshop :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants