quarkiverse / quarkus-google-cloud-services

Google Cloud Services Quarkus Extensions
https://docs.quarkiverse.io/quarkus-google-cloud-services/main/index.html
Apache License 2.0
54 stars 33 forks source link

Secret manager is not working with jdbc #132

Closed bgizdov closed 3 years ago

bgizdov commented 3 years ago

Hi,

I am trying to use secret manager for JDBC username and password, but I get errors. I suppose JDBC is initialized before GCP config, and that is the reason for the errors. If I just use secrets that are injected in beans it is working fine.

If you have ideas on how to fix or work around this issue, please share your thoughts.

Note: Maybe it is something similar to #109

I am using the latest released version 0.7.0.

%prod.quarkus.datasource.username=${sm//prod-db-user}
%prod.quarkus.datasource.password=${sm//prod-db-pass}
%prod.quarkus.datasource.jdbc.url=jdbc:mysql://${DB_SERVER:localhost}:${DB_PORT:3306}/${DB_NAME}
INFO: HV000001: Hibernate Validator %s
Jun 04, 2021 10:56:49 PM org.hibernate.jpa.internal.util.LogHelper
INFO: HHH000204: Processing PersistenceUnitInfo [name: %s]
Jun 04, 2021 10:56:49 PM org.hibernate.Version
INFO: HHH000412: Hibernate ORM core version %s
Jun 04, 2021 10:56:49 PM org.hibernate.annotations.common.Version
INFO: HCANN000001: Hibernate Commons Annotations {%1$s}
Jun 04, 2021 10:56:49 PM org.hibernate.dialect.Dialect
INFO: HHH000400: Using dialect: %s
Jun 04, 2021 10:56:49 PM Hibernate Types
INFO: This framework is proudly powered by:

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 _    _                           _     _
| |  | |                         (_)   | |
| |__| |_   _ _ __   ___ _ __ ___ _ ___| |_ ___ _ __   ___ ___
|  __  | | | | '_ \ / _ \ '__/ __| / __| __/ _ \ '_ \ / __/ _ \
| |  | | |_| | |_) |  __/ |  \__ \ \__ \ ||  __/ | | | (_|  __/
|_|  |_|\__, | .__/ \___|_|  |___/_|___/\__\___|_| |_|\___\___|
         __/ | |
        |___/|_|

At Hypersistence, we only build amazing tools, like Hibernate Types, Flexy Pool, or Hypersistence Optimizer.
What if there was a tool that could automatically detect JPA and Hibernate performance issues?
Hypersistence Optimizer is that tool!
For more details, go to:

https://vladmihalcea.com/hypersistence-optimizer/
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Jun 04, 2021 10:56:50 PM io.quarkus.runtime.ApplicationLifecycleManager run
ERROR: Failed to start application (with profile dev)
javax.enterprise.inject.CreationException: Config root [io.quarkiverse.googlecloudservices.common.GcpConfiguration] with config phase [RUN_TIME] not initialized yet.
    at io.quarkiverse.googlecloudservices.common.GcpConfiguration_f5f0cfc0930d359f64931c3293f018103e1bfca6_Synthetic_Bean.create(GcpConfiguration_f5f0cfc0930d359f64931c3293f018103e1bfca6_Synthetic_Bean.zig:112)
    at io.quarkiverse.googlecloudservices.common.GcpConfiguration_f5f0cfc0930d359f64931c3293f018103e1bfca6_Synthetic_Bean.get(GcpConfiguration_f5f0cfc0930d359f64931c3293f018103e1bfca6_Synthetic_Bean.zig:146)
    at io.quarkiverse.googlecloudservices.common.GcpConfiguration_f5f0cfc0930d359f64931c3293f018103e1bfca6_Synthetic_Bean.get(GcpConfiguration_f5f0cfc0930d359f64931c3293f018103e1bfca6_Synthetic_Bean.zig:169)
    at io.quarkus.arc.impl.CurrentInjectionPointProvider.get(CurrentInjectionPointProvider.java:52)
    at io.quarkiverse.googlecloudservices.secretmanager.runtime.SecretManagerProducer_Bean.create(SecretManagerProducer_Bean.zig:244)
    at io.quarkiverse.googlecloudservices.secretmanager.runtime.SecretManagerProducer_Bean.create(SecretManagerProducer_Bean.zig:327)
    at io.quarkus.arc.impl.AbstractSharedContext.createInstanceHandle(AbstractSharedContext.java:96)
    at io.quarkus.arc.impl.AbstractSharedContext.access$000(AbstractSharedContext.java:14)
    at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:29)
    at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:26)
    at io.quarkus.arc.impl.LazyValue.get(LazyValue.java:26)
    at io.quarkus.arc.impl.ComputingCache.computeIfAbsent(ComputingCache.java:69)
    at io.quarkus.arc.impl.AbstractSharedContext.get(AbstractSharedContext.java:26)
    at io.quarkus.arc.impl.ClientProxies.getApplicationScopedDelegate(ClientProxies.java:17)
    at io.quarkiverse.googlecloudservices.secretmanager.runtime.SecretManagerProducer_ClientProxy.arc$delegate(SecretManagerProducer_ClientProxy.zig:67)
    at io.quarkiverse.googlecloudservices.secretmanager.runtime.SecretManagerProducer_ClientProxy.arc_contextualInstance(SecretManagerProducer_ClientProxy.zig:82)
    at io.quarkiverse.googlecloudservices.secretmanager.runtime.SecretManagerProducer_ProducerMethod_secretManagerClient_da0d037e46ea741b638dc55997e8c2b5dd43f779_Bean.create(SecretManagerProducer_ProducerMethod_secretManagerClient_da0d037e46ea741b638dc55997e8c2b5dd43f779_Bean.zig:186)
    at io.quarkiverse.googlecloudservices.secretmanager.runtime.SecretManagerProducer_ProducerMethod_secretManagerClient_da0d037e46ea741b638dc55997e8c2b5dd43f779_Bean.create(SecretManagerProducer_ProducerMethod_secretManagerClient_da0d037e46ea741b638dc55997e8c2b5dd43f779_Bean.zig:204)
    at io.quarkus.arc.impl.AbstractSharedContext.createInstanceHandle(AbstractSharedContext.java:96)
    at io.quarkus.arc.impl.AbstractSharedContext.access$000(AbstractSharedContext.java:14)
    at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:29)
    at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:26)
    at io.quarkus.arc.impl.LazyValue.get(LazyValue.java:26)
    at io.quarkus.arc.impl.ComputingCache.computeIfAbsent(ComputingCache.java:69)
    at io.quarkus.arc.impl.AbstractSharedContext.get(AbstractSharedContext.java:26)
    at io.quarkiverse.googlecloudservices.secretmanager.runtime.SecretManagerProducer_ProducerMethod_secretManagerClient_da0d037e46ea741b638dc55997e8c2b5dd43f779_Bean.get(SecretManagerProducer_ProducerMethod_secretManagerClient_da0d037e46ea741b638dc55997e8c2b5dd43f779_Bean.zig:236)
    at io.quarkiverse.googlecloudservices.secretmanager.runtime.SecretManagerProducer_ProducerMethod_secretManagerClient_da0d037e46ea741b638dc55997e8c2b5dd43f779_Bean.get(SecretManagerProducer_ProducerMethod_secretManagerClient_da0d037e46ea741b638dc55997e8c2b5dd43f779_Bean.zig:252)
    at io.quarkus.arc.impl.ArcContainerImpl.beanInstanceHandle(ArcContainerImpl.java:430)
    at io.quarkus.arc.impl.ArcContainerImpl.beanInstanceHandle(ArcContainerImpl.java:443)
    at io.quarkus.arc.impl.ArcContainerImpl.instanceHandle(ArcContainerImpl.java:413)
    at io.quarkus.arc.impl.ArcContainerImpl.instance(ArcContainerImpl.java:222)
    at io.quarkiverse.googlecloudservices.secretmanager.runtime.config.SecretManagerClientProvider.get(SecretManagerClientProvider.java:18)
    at io.quarkiverse.googlecloudservices.secretmanager.runtime.config.SecretManagerConfigSource.getValue(SecretManagerConfigSource.java:40)
    at io.smallrye.config.ConfigValueConfigSourceWrapper.getConfigValue(ConfigValueConfigSourceWrapper.java:20)
    at io.smallrye.config.SmallRyeConfigSourceInterceptor.getValue(SmallRyeConfigSourceInterceptor.java:26)
    at io.smallrye.config.SmallRyeConfigSourceInterceptorContext.proceed(SmallRyeConfigSourceInterceptorContext.java:20)
    at io.smallrye.config.SmallRyeConfigSourceInterceptor.getValue(SmallRyeConfigSourceInterceptor.java:27)
    at io.smallrye.config.SmallRyeConfigSourceInterceptorContext.proceed(SmallRyeConfigSourceInterceptorContext.java:20)
    at io.smallrye.config.SmallRyeConfigSourceInterceptor.getValue(SmallRyeConfigSourceInterceptor.java:27)
    at io.smallrye.config.SmallRyeConfigSourceInterceptorContext.proceed(SmallRyeConfigSourceInterceptorContext.java:20)
    at io.smallrye.config.SmallRyeConfigSourceInterceptor.getValue(SmallRyeConfigSourceInterceptor.java:27)
    at io.smallrye.config.SmallRyeConfigSourceInterceptorContext.proceed(SmallRyeConfigSourceInterceptorContext.java:20)
    at io.smallrye.config.SmallRyeConfigSourceInterceptor.getValue(SmallRyeConfigSourceInterceptor.java:27)
    at io.smallrye.config.SmallRyeConfigSourceInterceptorContext.proceed(SmallRyeConfigSourceInterceptorContext.java:20)
    at io.smallrye.config.SmallRyeConfigSourceInterceptor.getValue(SmallRyeConfigSourceInterceptor.java:27)
    at io.smallrye.config.SmallRyeConfigSourceInterceptorContext.proceed(SmallRyeConfigSourceInterceptorContext.java:20)
    at io.smallrye.config.SmallRyeConfigSourceInterceptor.getValue(SmallRyeConfigSourceInterceptor.java:27)
    at io.smallrye.config.SmallRyeConfigSourceInterceptorContext.proceed(SmallRyeConfigSourceInterceptorContext.java:20)
    at io.smallrye.config.SecretKeysConfigSourceInterceptor.getValue(SecretKeysConfigSourceInterceptor.java:22)
    at io.smallrye.config.SmallRyeConfigSourceInterceptorContext.proceed(SmallRyeConfigSourceInterceptorContext.java:20)
    at io.smallrye.config.RelocateConfigSourceInterceptor.getValue(RelocateConfigSourceInterceptor.java:26)
    at io.smallrye.config.SmallRyeConfigSourceInterceptorContext.proceed(SmallRyeConfigSourceInterceptorContext.java:20)
    at io.smallrye.config.ProfileConfigSourceInterceptor.getValue(ProfileConfigSourceInterceptor.java:70)
    at io.smallrye.config.SmallRyeConfigSourceInterceptorContext.proceed(SmallRyeConfigSourceInterceptorContext.java:20)
    at io.smallrye.config.ExpressionConfigSourceInterceptor.getValue(ExpressionConfigSourceInterceptor.java:26)
    at io.smallrye.config.ExpressionConfigSourceInterceptor.lambda$getValue$0(ExpressionConfigSourceInterceptor.java:38)
    at io.smallrye.common.expression.ExpressionNode.emit(ExpressionNode.java:22)
    at io.smallrye.common.expression.Expression.evaluateException(Expression.java:56)
    at io.smallrye.common.expression.Expression.evaluate(Expression.java:70)
    at io.smallrye.config.ExpressionConfigSourceInterceptor.getValue(ExpressionConfigSourceInterceptor.java:37)
    at io.smallrye.config.ExpressionConfigSourceInterceptor.getValue(ExpressionConfigSourceInterceptor.java:18)
    at io.smallrye.config.SmallRyeConfigSourceInterceptorContext.proceed(SmallRyeConfigSourceInterceptorContext.java:20)
    at io.smallrye.config.SmallRyeConfig.getConfigValue(SmallRyeConfig.java:285)
    at io.smallrye.config.SmallRyeConfig.getValue(SmallRyeConfig.java:227)
    at io.quarkus.runtime.generated.Config.initGroup$io$quarkus$datasource$runtime$DataSourceRuntimeConfig(Config.zig:27391)
    at io.quarkus.runtime.generated.Config.initGroup$io$quarkus$datasource$runtime$DataSourcesRuntimeConfig(Config.zig:17604)
    at io.quarkus.runtime.generated.Config.readConfig(Config.zig:2334)
    at io.quarkus.deployment.steps.RuntimeConfigSetup.deploy(RuntimeConfigSetup.zig:60)
    at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:662)
    at io.quarkus.runtime.Application.start(Application.java:90)
    at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:100)
    at io.quarkus.runtime.Quarkus.run(Quarkus.java:66)
    at io.quarkus.runtime.Quarkus.run(Quarkus.java:42)
    at io.quarkus.runtime.Quarkus.run(Quarkus.java:119)
    at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:29)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:567)
    at io.quarkus.runner.bootstrap.StartupActionImpl$3.run(StartupActionImpl.java:134)
    at java.base/java.lang.Thread.run(Thread.java:830)

Jun 04, 2021 10:56:50 PM io.quarkus.deployment.dev.IsolatedDevModeMain firstStart
INFO: Attempting to start hot replacement endpoint to recover from previous Quarkus startup failure
Quarkus application exited with code 1
Press Enter to restart or Ctrl + C to quit
Jun 04, 2021 10:56:50 PM io.quarkus.deployment.dev.IsolatedDevModeMain firstStart
ERROR: Failed to recover after failed start
java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: SRCFG00013: No Converter registered for interface java.nio.file.Path
    at io.quarkus.vertx.http.runtime.VertxHttpRecorder.startServerAfterFailedStart(VertxHttpRecorder.java:228)
    at io.quarkus.vertx.http.runtime.devmode.VertxHttpHotReplacementSetup.handleFailedInitialStart(VertxHttpHotReplacementSetup.java:39)
    at io.quarkus.deployment.dev.RuntimeUpdatesProcessor.startupFailed(RuntimeUpdatesProcessor.java:653)
    at io.quarkus.deployment.dev.IsolatedDevModeMain.firstStart(IsolatedDevModeMain.java:137)
    at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:378)
    at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:56)
    at io.quarkus.bootstrap.app.CuratedApplication.runInCl(CuratedApplication.java:127)
    at io.quarkus.bootstrap.app.CuratedApplication.runInAugmentClassLoader(CuratedApplication.java:84)
    at io.quarkus.deployment.dev.DevModeMain.start(DevModeMain.java:144)
    at io.quarkus.deployment.dev.DevModeMain.main(DevModeMain.java:63)
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: SRCFG00013: No Converter registered for interface java.nio.file.Path
    at io.quarkus.runtime.configuration.ConfigInstantiator.handleObject(ConfigInstantiator.java:106)
    at io.quarkus.runtime.configuration.ConfigInstantiator.handleObject(ConfigInstantiator.java:57)
    at io.quarkus.vertx.http.runtime.VertxHttpRecorder.startServerAfterFailedStart(VertxHttpRecorder.java:200)
    ... 9 more
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: SRCFG00013: No Converter registered for interface java.nio.file.Path
    at io.quarkus.runtime.configuration.ConfigInstantiator.handleObject(ConfigInstantiator.java:106)
    at io.quarkus.runtime.configuration.ConfigInstantiator.handleObject(ConfigInstantiator.java:79)
    ... 11 more
Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException: SRCFG00013: No Converter registered for interface java.nio.file.Path
    at io.quarkus.runtime.configuration.ConfigInstantiator.handleObject(ConfigInstantiator.java:106)
    at io.quarkus.runtime.configuration.ConfigInstantiator.handleObject(ConfigInstantiator.java:79)
    ... 12 more
Caused by: java.lang.IllegalArgumentException: SRCFG00013: No Converter registered for interface java.nio.file.Path
    at io.smallrye.config.SmallRyeConfig.lambda$getConverter$2(SmallRyeConfig.java:415)
    at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1705)
    at io.smallrye.config.SmallRyeConfig.getConverter(SmallRyeConfig.java:412)
    at io.quarkus.runtime.configuration.ConfigInstantiator.getConverterFor(ConfigInstantiator.java:121)
    at io.quarkus.runtime.configuration.ConfigInstantiator.getConverterFor(ConfigInstantiator.java:117)
    at io.quarkus.runtime.configuration.ConfigInstantiator.handleObject(ConfigInstantiator.java:91)
    ... 13 more
loicmathieu commented 3 years ago

Do you use the latest version published a few days ago, 0.7.0. It contains a fix that should have solved this issue.

bgizdov commented 3 years ago

Yes, I saw this fix, and I am using the latest version 0.7.0.

loicmathieu commented 3 years ago

So I'll need a reproducer project because the fix should have fixed your issue.

bgizdov commented 3 years ago

Hi @loicmathieu ,

I created a test project here https://github.com/bgizdov/secret-manager-test

The error log when start quarkus https://github.com/bgizdov/secret-manager-test/blob/main/error.log

I noticed that if you comment regular env config and uncomment ${sm//foobar} config while the app is running, then the code is hot replaced, and it is able to get the secrets from google secret manager.

loicmathieu commented 3 years ago

Fixed via #154

bgizdov commented 3 years ago

@loicmathieu I confirm, it works now with v0.9.0. Thanks