-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Wildcard locations for configs causes files to be parsed multiple times on k8s #23160
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
Comments
When a wildcard directory is configured as a search location, the code will only search one directory level deep to find property files. So just setting one additional search location with a wildcard won't cause the reported issue. The scenario described can be reproduced by setting two additional search locations. Assuming
Property sources loaded by a location with a wildcard don't have the @leonard84 Can you confirm that your example has multiple additional search locations configured? Setting two additional locations like this is a valid use-case, because it is reasonable for someone to set up a configuration with with configmaps mounted at multiple locations like |
@scottfrederick we didn't configure any special parameters. Our working directory is |
This fix is causing running Sprint Boot on eclipse tomcat servers, not to pick up the configurations file, as eclipse deploys the application on a path containing "." |
Thank you @mena149f. We're aware of the problem and that's fixed in the upcoming |
@snicoll Please consider 62aa1b7#commitcomment-44079277 This is not a fix. |
@bo0ts Sorry, I don't understand why only ignoring If you would like us to reconsider, please comment on #23983 and provide a complete and minimal sample that demonstrates the problem. |
@wilkinsona We are using fully qualified paths to set our config locations, e.g. This change breaks loading our configs and #23983 does nothing to alleviate this. I don't think skipping explicitly defined absolute paths to config files is the intention. |
@bo0ts may I ask why you list those files explicitly instead of just listing the folders to be searched? |
I wondered about this also. IIUC, the folders with names like |
@leonard84 @scottfrederick You are certainly right and we should at least specify the symlinks. However we explicitly decided against specifying the directories because we did not want to rely on yet another implicit mechanism for loading settings and because the behavior is different between Spring Boot 1.5 and 2 (which we both have to support with this script). |
@bo0ts you can then simply use the non hidden symlinks, like k8s intended. You script might need to be a little fancier than a simple Untested: At the end you want to have this:
|
With the release of 2.3 there where some changes to how config files were loaded. The new wildcard support causes files to be loaded multiple times if they are in mounted k8s configmaps. The reason is an implementation detail of k8s that uses double symlink indirection.
A mounted config map produces a layout like this:
Spring will happily parse every file that it can find:
This can cause weird errors, depending on the application.
Also note that for some reason the files in subdirs don't have the
file:
scheme.I'd suggest to not parse files and directories starting with a
.
Spring Boot version 2.3.1
The text was updated successfully, but these errors were encountered: