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

Google Secret Manager client fails to retrieve secret when executed from native image #775

Open
montesmoci opened this issue Mar 2, 2023 · 3 comments
Labels
info: workaround available A workaround is available for the issue relates-to: graal status: awaiting validation Waiting to be validated as a real issue

Comments

@montesmoci
Copy link

Expected Behavior

Successful retrieval and reading of a secret stored in Secret Manager.

Actual Behaviour

The following stack trace is generated when attempting to retrieve a secret:

Mar 02, 2023 9:47:30 AM io.grpc.auth.GoogleAuthLibraryCallCredentials createJwtHelperOrNull
WARNING: Failed to create JWT helper. This is unexpected
java.lang.NoSuchMethodException: com.google.auth.oauth2.ServiceAccountCredentials.getQuotaProjectId()
        at java.lang.Class.getMethod(DynamicHub.java:2227)
        at io.grpc.auth.GoogleAuthLibraryCallCredentials$JwtHelper.<init>(GoogleAuthLibraryCallCredentials.java:318)
        at io.grpc.auth.GoogleAuthLibraryCallCredentials.createJwtHelperOrNull(GoogleAuthLibraryCallCredentials.java:224)
        at io.grpc.auth.GoogleAuthLibraryCallCredentials.<clinit>(GoogleAuthLibraryCallCredentials.java:53)
        at io.grpc.auth.MoreCallCredentials.from(MoreCallCredentials.java:35)
        at com.google.api.gax.grpc.GrpcCallContext.withCredentials(GrpcCallContext.java:160)
        at com.google.api.gax.grpc.GrpcCallContext.withCredentials(GrpcCallContext.java:67)
        at com.google.api.gax.rpc.ClientContext.create(ClientContext.java:206)
        at com.google.cloud.secretmanager.v1.stub.GrpcSecretManagerServiceStub.create(GrpcSecretManagerServiceStub.java:248)
        at com.google.cloud.secretmanager.v1.stub.SecretManagerServiceStubSettings.createStub(SecretManagerServiceStubSettings.java:349)
        at com.google.cloud.secretmanager.v1.SecretManagerServiceClient.<init>(SecretManagerServiceClient.java:180)
        at com.google.cloud.secretmanager.v1.SecretManagerServiceClient.create(SecretManagerServiceClient.java:162)
        at com.google.cloud.secretmanager.v1.SecretManagerServiceClient.create(SecretManagerServiceClient.java:153)
        at bug.nativeCompile.googleSecretManager.ApplicationSecretsClient.onStartup(ApplicationSecretsClient.java:35)
        at bug.nativeCompile.googleSecretManager.$ApplicationSecretsClient$Definition$Exec.dispatch(Unknown Source)
        at io.micronaut.context.AbstractExecutableMethodsDefinition$DispatchedExecutableMethod.invoke(AbstractExecutableMethodsDefinition.java:371)
        at io.micronaut.context.DefaultBeanContext$BeanExecutionHandle.invoke(DefaultBeanContext.java:3828)
        at io.micronaut.aop.chain.AdapterIntroduction.intercept(AdapterIntroduction.java:83)
        at io.micronaut.aop.chain.MethodInterceptorChain.proceed(MethodInterceptorChain.java:137)
        at bug.nativeCompile.googleSecretManager.ApplicationSecretsClient$ApplicationEventListener$onStartup1$Intercepted.onApplicationEvent(Unknown Source)
        at io.micronaut.context.event.ApplicationEventPublisherFactory.notifyEventListeners(ApplicationEventPublisherFactory.java:262)
        at io.micronaut.context.event.ApplicationEventPublisherFactory.access$200(ApplicationEventPublisherFactory.java:60)
        at io.micronaut.context.event.ApplicationEventPublisherFactory$2.publishEvent(ApplicationEventPublisherFactory.java:229)
        at io.micronaut.context.DefaultBeanContext.publishEvent(DefaultBeanContext.java:1703)
        at io.micronaut.context.DefaultBeanContext.start(DefaultBeanContext.java:356)
        at io.micronaut.context.DefaultApplicationContext.start(DefaultApplicationContext.java:194)
        at io.micronaut.runtime.Micronaut.start(Micronaut.java:75)
        at io.micronaut.runtime.Micronaut.run(Micronaut.java:323)
        at io.micronaut.runtime.Micronaut.run(Micronaut.java:309)
        at bug.nativeCompile.googleSecretManager.Application.main(Application.java:8)

Steps To Reproduce

  1. Assuming one has a GCP account and has the following secret with the name secret_txt (see line 16 of bug/nativeCompile/googleSecretManager/ApplicationSecretsClient.java).
  2. Change the gcp.project-id in application.yml to the relevant value.
  3. Use GraalVM via sdk man or some other means. On my end, I enable GraalVM via sdk use java 22.2.r17-grl
  4. Execute ./gradlew nativeCompile.
  5. Run the generated native image ./build/native/nativeCompile/bug-nativeCompile-googleSecretManager
  6. Observe that io.grpc.auth.GoogleAuthLibraryCallCredentials createJwtHelperOrNull WARNING: Failed to create JWT helper. This is unexpected java.lang.NoSuchMethodException: com.google.auth.oauth2.ServiceAccountCredentials.getQuotaProjectId() error is generated. The above error is not generated whenever ./gradlew run is executed.

Environment Information

  • OS Ventura - 13.1 (22C65)
  • Apple M1 Pro
  • Java 22.2.r17-gr

Example Application

https://github.com/montesmoci/bug-nativeCompile-googleSecretsManager

Version

3.8.6

@graemerocher
Copy link
Contributor

@sdelamo sdelamo added relates-to: graal status: awaiting validation Waiting to be validated as a real issue labels Mar 2, 2023
@montesmoci
Copy link
Author

FYI: Adding implementation("com.google.cloud:google-cloud-secretmanager:2.12.0") resolves the issue.

@graemerocher graemerocher added the info: workaround available A workaround is available for the issue label Mar 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info: workaround available A workaround is available for the issue relates-to: graal status: awaiting validation Waiting to be validated as a real issue
Projects
None yet
Development

No branches or pull requests

3 participants