-
Notifications
You must be signed in to change notification settings - Fork 34
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
No longer possible to use secret-manager injected secret in @ConfigMapping class #491
Comments
@radcortez with the new way to load config source, it is no longer possible to inject config from the Google Cloud Secret Manager inside a config mapping. Is it a known limitation? Is there a fix or a workaround? |
Configs loaded by the Factories are available in the mappings phase, but looking into the stacktrace, there shouldn't be a call to @jaworskib can you please provide a small reproducer so I can look into it? Thanks! |
@radcortez sure, here you have a small reproducer: https://github.com/jaworskib/secret-manager-config-mapping Thanks for looking into it! |
Thanks. I'll have a look. |
@jaworskib any chance to try out #493? |
I'll try it tomorrow, but to be honest I'm not sure about the approach. It seems like this approach requires adding some additional permissions to SA to be able to list Update: |
Thanks! It's a bit hard to test this. I couldn't find a proper way to emulate the SM, so I created my own and did some tests. Unfortunately, I'm not aware of all the options available. We removed the ability that allowed us to use CDI during source creation because it caused many issues. It created chicken and egg scenarios, where you need config to start something, but you require something to create the config. The previous implementation relied on CDI to provide the client, which CDI managed and closed. The Config components do not have a way to clean up resources, meaning that we either have to do it in the factories (as proposed), or we would need to create and close the client on each value lookup. I guess from what you describe there is no other option. I'll have look again. |
I had to update my previous comment as it was only a partially true. Maybe the proposed approach isn't that bad at all but it definitely should be a well documented that this extension will try to access all secrets (and all it's versions) that can be listed by the credentials used and additional permissions are required (in the ideal world The other approach I can think of (beside the one with creating and closing the client on each value lookup) would be to scan all the properties with the |
Hi, thanks @radcortez for the proposed fix and @jaworskib for the explanation. If I understand it correctly, the main difference is that now all secrets are retrieved at first call when previously they was retrieved one by one when needed.
This seems a good idea as otherwise we will access secrets that are not needed, and API calls have cost in the cloud. |
Unfortunately, I don't think this is feasible, because the Also, some configuration sources, do not expose all of their value, in the sense that if you query for a name you may get a value, but if you query for the list of names you get an empty list. In that case, we may be missing values that contain the Anyway, I have another idea to be able to have the client and clean it properly. I'll send a new update soon. |
Ok, I reverted to the old source, still without CDI, and added a way to close the client on shutdown. It should work for most cases. The only problem is if an application is playing with Config instances (which they shouldn't), then these are required to do the cleanup themselves. |
I have a simple application with the following setup:
and a following @ConfigMapping interface:
Everything was working fine in the version 2.2.0 but since version 2.3.0 application startup ends with the following error:
which is a result of
It seems like a direct cause of this error was a ConfigPhase change for GcpBootstrapConfiguration.
Do you plan to still support something like described above? Is there any known workaround for my case?
The text was updated successfully, but these errors were encountered: