spring-cloud-config icon indicating copy to clipboard operation
spring-cloud-config copied to clipboard

Possible Precedence issue with common vs. app-specific config and profiles

Open kcbaltz opened this issue 3 years ago • 1 comments

We recently upgraded our app to Spring Boot 2.4+ and our config server to 3.1.4 and found an issue with precedence of different config files. I'm not sure if I have the wrong expectation or if this is a bug.

We have the following config files in our Git repo:

application.yml application-qa.yml foo.yml (includes a default doc and a doc with spring.config.active.on-profile: qa)

Assume our app is named "foo". If I put the same property name in all three files with different values, the one that "wins" is the one in application-qa.yml when qa is the active profile. I.e.

  1. application-qa.yml
  2. foo.yml (for qa profile)
  3. foo.yml (for the default doc)
  4. application.yml

I can see this in my app as well as by hitting the config server directly, in which case the docs appear in the result in the above order. I would have expected application-qa.yml to be #3. I.e.

  1. foo.yml (for qa profile)
  2. foo.yml (for the default doc)
  3. application-qa.yml
  4. application.yml

The docs make it clear that application.yml should lose to foo.yml and that is working, but it's less clear on application-{profile}.yml files. I'm considering migrating the values in our application-{profile}.yml files into profile activated docs within the application.yml file because this seems to achieve the desired precedence, but it doesn't seem like we should have to do this (and it's not a small change and we'd have to test against all our apps).

kcbaltz avatar Jun 27 '22 18:06 kcbaltz

Doing some further experimentation, I'm finding that if I add a foo-qa.yml file, that will win over a application-qa.yml which seems to make sense. This does seem to be different from the old config server (2.2) which prioritized the qa profile section of foo.yml over anything in application-qa.yml

kcbaltz avatar Jun 27 '22 19:06 kcbaltz

Were you able to solve this issue? Have you tried with the latest versions of Spring Boot and Spring Cloud?

ryanjbaxter avatar Nov 03 '22 00:11 ryanjbaxter

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

spring-cloud-issues avatar Nov 10 '22 00:11 spring-cloud-issues

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

spring-cloud-issues avatar Nov 17 '22 00:11 spring-cloud-issues