Skip to content
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

ConfigDataLocationNotFoundException thrown at application startup with configserver: config imports, that are not even meant for the current profile #24584

Closed
dnijssen opened this issue Dec 22, 2020 · 7 comments
Assignees
Labels
type: regression A regression from a previous release
Milestone

Comments

@dnijssen
Copy link

dnijssen commented Dec 22, 2020

Since upgrading from 2.4.0 to 2.4.1 (same for 2.4.2-SNAPSHOT) my application fails to startup due the following exception;

  • Using Spring Cloud version 2020.0.0-RC1
06:46:34.776 [main] DEBUG org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter - Application failed to start due to an exception
org.springframework.boot.context.config.ConfigDataLocationNotFoundException: Config data location 'configserver:https://prod-configuration-server.org' cannot be found
	at org.springframework.boot.context.config.ConfigDataEnvironment.checkMandatoryLocations(ConfigDataEnvironment.java:360)
	at org.springframework.boot.context.config.ConfigDataEnvironment.applyToEnvironment(ConfigDataEnvironment.java:313)
	at org.springframework.boot.context.config.ConfigDataEnvironment.processAndApply(ConfigDataEnvironment.java:233)
	at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:97)
	at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:89)
	at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEnvironmentPreparedEvent(EnvironmentPostProcessorApplicationListener.java:100)
	at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEvent(EnvironmentPostProcessorApplicationListener.java:86)

I think this is originally caused by improvements made in 3dc03ac

This occurs with the following setup; (starting up with both default profile as the local profile (-Dspring.profiles.active=local)

spring:
  application:
    name: foobar
  profiles:
    active: local

---

spring:
  config:
    activate:
      on-profile: local, docker
    import: configserver:http://localhost:8888

---

spring:
  config:
    activate:
      on-profile: dev, test
    import: configserver:https://test-configuration-server.org

---

spring:
  config:
    activate:
      on-profile: acc
    import: configserver:https://acc-configuration-server.org

---

spring:
  config:
    activate:
      on-profile: prd
    import: configserver:https://prod-configuration-server.org

In my understanding this exception is thrown because all mandatory locations are checked, and not just one from the active profile. I would expect it to nicely skip the configserver: imports for both dev, test, acc, prd in the above example. Even though they are not optional, they are not meant for the active profile either.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 22, 2020
@dnijssen dnijssen changed the title ConfigDataLocationNotFoundException thrown at application startup with configserver: config imports, that are not even for the current profile ConfigDataLocationNotFoundException thrown at application startup with configserver: config imports, that are not even meant for the current profile Dec 22, 2020
@spencergibb
Copy link
Member

What version of Spring Cloud are you using?

@dnijssen
Copy link
Author

dnijssen commented Dec 22, 2020

Using Spring Cloud version 2020.0.0-RC1, as I did with Spring Boot 2.4.0 as well before. So the breaking change seems to be part of Spring Boot

@snicoll
Copy link
Member

snicoll commented Dec 22, 2020

So the breaking change seems to be part of Spring Boot

@dnijssen Using an old Spring Cloud version against a newer spring boot version isn't the right thing to do. This feature is tightly integrated in Spring Cloud and we had to do some changes in 2.4.1 to help ironing things in Spring Cloud config server. Please try with the latest Spring Cloud 2020.0.0.

Edit: To make that hopefully more clear, 2020.0.0-SNAPSHOT.

@snicoll snicoll added the status: waiting-for-feedback We need additional information before we can continue label Dec 22, 2020
@dnijssen
Copy link
Author

Same issue occurs when running Spring Boot 2.4.1 with Spring Cloud 2020.0.0-SNAPSHOT

backend_1   | 08:41:37.871 [main] DEBUG org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter - Application failed to start due to an exception
backend_1   | org.springframework.boot.context.config.ConfigDataLocationNotFoundException: Config data location 'configserver:https://prod-configuration-server.org' cannot be found
backend_1   |   at org.springframework.boot.context.config.ConfigDataEnvironment.checkMandatoryLocations(ConfigDataEnvironment.java:344)
backend_1   |   at org.springframework.boot.context.config.ConfigDataEnvironment.applyToEnvironment(ConfigDataEnvironment.java:300)
backend_1   |   at org.springframework.boot.context.config.ConfigDataEnvironment.processAndApply(ConfigDataEnvironment.java:224)
backend_1   |   at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:88)
backend_1   |   at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:80)

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Dec 22, 2020
@mbhave
Copy link
Contributor

mbhave commented Dec 22, 2020

Thanks for checking @dnijssen. I was able to reproduce this in Spring Boot. I think it's a bug that we check mandatory locations even when the profile isn't active.

@mbhave mbhave added type: bug A general bug and removed status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged labels Dec 22, 2020
@mbhave mbhave added this to the 2.4.x milestone Dec 22, 2020
@dnijssen
Copy link
Author

Thank you for confirming @mbhave , I have just verified the same thing as well on advice of @spencergibb. He asked me to check whether the same thing was happening when just using file:./non-existing.yaml. And it indeed exists in that case as well, confirming the bug that you described above, namely checking mandatory locations for inactive profiles.

@snicoll
Copy link
Member

snicoll commented Dec 23, 2020

@mbhave shouldn't this be flagged a regression?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: regression A regression from a previous release
Projects
None yet
Development

No branches or pull requests

5 participants