spring-attic / spring-cloud-gcp

Integration for Google Cloud Platform APIs with Spring
Apache License 2.0
705 stars 693 forks source link

@RefreshScope failing when we use a "sm:" reference in properties. #2485

Closed tlintz closed 3 years ago

tlintz commented 4 years ago

(Apologies for creating yet another bug report :/ )

The idea was to have a @ConfigurationProperties bean and make use of @RefreshScope to refresh the properties through /actuator/refresh trigger. But when the properties have a "${sm://abc}" reference, I'm getting an exception AFTER the /actuator/refresh end point is triggered:

Caused by: java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask@11a98da3[Not completed, task = java.util.concurrent.Executors$RunnableAdapter@635136e1[Wrapped task = io.grpc.internal.SerializingExecutor@2170fb52]] rejected from java.util.concurrent.ScheduledThreadPoolExecutor@2e947433[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0]
    at java.base/java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2055) ~[na:na]
    at java.base/java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:825) ~[na:na]
    at java.base/java.util.concurrent.ScheduledThreadPoolExecutor.delayedExecute(ScheduledThreadPoolExecutor.java:340) ~[na:na]
    at java.base/java.util.concurrent.ScheduledThreadPoolExecutor.schedule(ScheduledThreadPoolExecutor.java:562) ~[na:na]
    at java.base/java.util.concurrent.ScheduledThreadPoolExecutor.execute(ScheduledThreadPoolExecutor.java:705) ~[na:na]

To reproduce: -Create a simple boot app, with Actuator and Secret Manager dependency -Have a Bean making use of @RefreshScope -Enable in properties: management.endpoints.web.exposure.include: refresh
-Have a property in your property file that refers to a variable in Secret Manager. (sm://), and make sure to use that property if your code/bean. -Start the app and trigger the POST {context}/actuator/refresh

You will see the exception above.

Thanks!

Related to: #2115

meltsufin commented 4 years ago

Thanks for the report @tlintz!

@dzou Can you take a look when you have a chance? We should be able to reproduce with slight modification to our secrets manager sample app.

dzou commented 4 years ago

Hey sorry for the delay on this.

We've isolated the problem and asked how to fix it here: https://github.com/spring-cloud/spring-cloud-commons/issues/833

There is basically a complication with an interaction with Actuator and our property source; our usage of PropertySource is not typical as we query secret manager as needed and we do not know what are all the secrets a user might use on bean creation. Will see if we can come up with a solution.

dzou commented 3 years ago

Unfortunately it looks like this is not possible based on the response in: https://github.com/spring-cloud/spring-cloud-commons/issues/833

Will need to implement the new config.import style for Secret Manager to enable this feature. Tracked here: https://github.com/GoogleCloudPlatform/spring-cloud-gcp/issues/149

MarcoR83 commented 3 years ago

Im having the same issue. Whats the solution for this? This issue was closed, this one https://github.com/GoogleCloudPlatform/spring-cloud-gcp/issues/149 is open, but the WIP PR was closed with "will revisit when we need it" well.. I definitly could use a working reload functionality when using gcp secret manager in my spring boot configuration..