quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.56k stars 2.62k forks source link

Native Build is missing GRPC generated class #42150

Open zilinjak opened 1 month ago

zilinjak commented 1 month ago

Describe the bug

Hello, Im implementing Envoy ext_authz GRPC service - here is proto file.

When running in quarkusDev all is working, once the native build is done and ran Im getting error. This error is displayed on grpcurl side:


grpcurl -plaintext -d '
{
    "attributes": {
        "request": {
            "http": {
                "headers": [
                    {
                        "key": "token",      
                        "value": ""
                    }
                ]
            }
        }
    }
}
'  localhost:8080 envoy.service.auth.v3.Authorization/Check
ERROR:
  Code: Unknown
  Message: java.lang.IllegalStateException - Generated message class "com.google.protobuf.Timestamp" missing method "newBuilder".

Expected behavior

Native build should be running the same as dev mode.

Actual behavior

Native build is missing some dependencies resulting in non working GRPC service.

How to Reproduce?

  1. Implement GRPC service from this proto file
  2. Run native build
  3. Send this request
    grpcurl -plaintext -d '
    {
    "attributes": {
        "request": {
            "http": {
                "headers": [
                    {
                        "key": "token",      
                        "value": ""
                    }
                ]
            }
        }
    }
    }
    '  localhost:8080 envoy.service.auth.v3.Authorization/Check

Output of uname -a or ver

Darwin MacBook-Air.local 23.4.0 Darwin Kernel Version 23.4.0: Fri Mar 15 00:12:41 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T8103 arm64

Output of java -version

java 21.0.3 2024-04-16 LTS Java(TM) SE Runtime Environment Oracle GraalVM 21.0.3+7.1 (build 21.0.3+7-LTS-jvmci-23.1-b37) Java HotSpot(TM) 64-Bit Server VM Oracle GraalVM 21.0.3+7.1 (build 21.0.3+7-LTS-jvmci-23.1-b37, mixed mode, sharing)

Quarkus version or git rev

3.7.4

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

------------------------------------------------------------ Gradle 8.5 ------------------------------------------------------------ Build time: 2023-11-29 14:08:57 UTC Revision: 28aca86a7180baa17117e0e5ba01d8ea9feca598 Kotlin: 1.9.20 Groovy: 3.0.17 Ant: Apache Ant(TM) version 1.10.13 compiled on January 4 2023 JVM: 21.0.3 (Oracle Corporation 21.0.3+7-LTS-jvmci-23.1-b37) OS: Mac OS X 14.4.1 aarch64

Additional information

No response

quarkus-bot[bot] commented 1 month ago

/cc @alesj (grpc), @cescoffier (grpc), @geoand (kotlin), @zakkak (native-image)

cescoffier commented 1 month ago

Seems to work for me:

 grpcurl -plaintext localhost:8080  envoy.service.auth.v3.Authorization.Check
{
  "ok_response": {}
}

Try with the latest Quarkus version.

cescoffier commented 1 month ago

BTW, here is my config:

quarkus.generate-code.grpc.scan-for-proto=io.envoyproxy.controlplane:api

quarkus.grpc.server.enable-reflection-service=true
quarkus.grpc.server.use-separate-server=false
zilinjak commented 1 month ago

Hey, thanks for fast response. I did upgrade to 3.11.1 ( when upgrading to 3.12 I was getting some errors ).

The problem is still happening, the generated source are in folder build/classes/java/quarkus-generated-sources.

The problem is only happening when the payload is NOT empty. I will showcase this on 2 examples

grpcurl -plaintext localhost:8080  envoy.service.auth.v3.Authorization.Check
{
  "ok_response": {}
}

grpcurl -plaintext -d '                                                     
{
    "attributes": {
        "request": {
            "http": {
                "headers": []    
            }                                
        }                          
    }        
}        
'  localhost:8080 envoy.service.auth.v3.Authorization/Check
ERROR:
  Code: Unknown
  Message: java.lang.IllegalStateException - Generated message class "com.google.protobuf.Timestamp" missing method "newBuilder".

My here is what may be important from my config:

quarkus.generate-code.grpc.scan-for-imports=all
quarkus.grpc.server.use-separate-server=false
quarkus.grpc.server.enable-reflection-service=true
quarkus.grpc.server.host=127.0.0.1

mp.jwt.verify.publickey.location=... auth url ...
# JWKs will be cached for 1 minute
smallrye.jwt.jwks.refresh-interval=1
# MAX INT - we don't want to validate exp claim by library
mp.jwt.verify.clock.skew=2147483647

also my dependencies in gradle.build.kts are:

    implementation("io.quarkus:quarkus-smallrye-health")
    implementation(enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}"))
    implementation("io.quarkus:quarkus-container-image-jib")
    implementation("io.quarkus:quarkus-grpc")
    implementation("io.quarkus:quarkus-smallrye-jwt")
    implementation("io.quarkus:quarkus-arc")
//    implementation("io.quarkus:quarkus-opentelemetry") @TODO currently disabled for local development + POC

    // Required for generated REST client
    implementation("com.squareup.moshi:moshi:1.15.1")
    implementation("com.squareup.moshi:moshi-kotlin:1.15.1")
    implementation("com.squareup.okhttp3:okhttp:4.12.0")

    testImplementation("io.quarkus:quarkus-junit5")

and plugins are:

    kotlin("jvm") version "1.9.20"
    kotlin("plugin.allopen") version "1.9.20"
    id("io.quarkus")
    id("org.openapi.generator") version "7.7.0"
    id("com.google.cloud.tools.jib") version "3.1.4"

The Timestamp class and its builder seems to be in library com.google.protobuf:protobuf-java:3.25.0 which I can see in IDEA.

cescoffier commented 1 month ago

I tried with and without payload, but without JWT. I'm wondering if that could be the issue.

Unfortunately, I'll be on PTO starting today for 3 weeks. I will investigate when I'm back (except if @alesj beats me on it)

geoand commented 1 week ago

Any updates on this?

cescoffier commented 1 week ago

No, did not have time to look at it.