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

spring.profiles.included not permitted in externalized non-profile-specific properties #24876

Closed
konradczajka opened this issue Jan 18, 2021 · 1 comment
Assignees
Labels
for: external-project For an external project and not something we can fix

Comments

@konradczajka
Copy link

konradczajka commented Jan 18, 2021

This issue relates highly to Spring Cloud Config but was introduced directly by changes made in #24733 (released in Spring Boot 2.4.2) so I report it here. I'll move it to SCC if needed.

In my current setup I share some common configuration between applications using profiles.
Configuration repository contains application.yml file with properties shared among all apps. There are also additional application-xxx.yml files containing properties shared by a subset of services e.g. application-rabbitmq.yml
App-specific, but not profile-specific files (e.g. calculator.yml) declares spring.profiles.include=rabbitmq property with all profiles that should be used to retrieve given app's config. All apps are started without marking any profiles as active/included.
This approach seems to be supported by Spring Cloud Config Server as well as when I request some app's config using the default profile (<config-server-uri>/calculator/default) in response I receive "main" files: application.yml, calculator.yml, as well as files specific to the declared profile: application-rabbitmq.yml. When I change spring.profiles.include in application.yml to other value, application-rabbitmq.yml is not included anymore. This means SCCS recognizes this property and takes it into account when determining which properties files should be returned.

Now to the main problem - the setup described above works well with Spring Boot 2.4.1 but has stopped after the upgrade to 2.4.2.
Now the client app crashes at startup with:

16:43:55.562 [main] ERROR org.springframework.boot.SpringApplication - Application run failed
org.springframework.boot.context.config.InvalidConfigDataPropertyException: Property 'spring.profiles.include' imported from location '[ConfigServerConfigDataResource@e84a8e1 uris = array<String>['http://localhost:8888'], optional = false, profiles = list['default']]' is invalid in a profile specific resource [origin: Config Server (snip)/calculator.yml:3:14]

InvalidConfigDataPropertyException throws an exception during processing of ConfigDataEnvironmentContributor instance responsible for handling cloud config server as a source. The contributor is marked as "profileSpecific" and therefore it's forbidden for it to contain "profiles properties".
When I move spring.profiles.include from calculator.yml to application.yml the app crashes as well.
I don't know what exactly causes the contributor to be marked as "profileSpecific". Spring Cloud Config Client makes a request to the Spring Cloud Config Server using "default" as profile name when the app was started without any profile, The response from the server looks like this:

    (...)
    "profiles": [
        "default"
    ],
    (...)
   "propertySources": [
        {
            "name": "(snip)/calculator.yml",
            "source": {
                (...)
            }
        },
        {
            "name": "(snip)/application-rabbitmq.yml",
            "source": {
                (...)
            }
        },
        {
            "name": "(snip)/application.yml",
            "source": {
                (...)
            }
        }
    ],

I created a simple repository with config server that presents the problem. It's even more simplified then the description above as configuration served by SCCS doesn't include an application-specific files, just appplication.yml and application-demo.yml:
https://github.com/konradczajka/cloud-config-profile-issue-demo

In my opinion it should be permitted to specify profiles in an external configuration as long as particular file is not profile-specific but I'm aware that there may be a good reason for forbidding that. I'd just like to know if that's a case and I'll just look for other solution to my sharing problem. And if It's not advised to include any profiles-related properties in any file served by SCCS then maybe its documentation should mention it.

Regards.

@philwebb
Copy link
Member

I've digged a bit and I think a change will be needed to Spring Cloud. I've opened spring-cloud/spring-cloud-config#1788.

@philwebb philwebb added for: external-project For an external project and not something we can fix and removed status: waiting-for-triage An issue we've not yet triaged labels Jan 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project For an external project and not something we can fix
Projects
None yet
Development

No branches or pull requests

3 participants