Skip to content

Version 4.0.4, unable to connect to Cloud Config if we have cloud config profile and spring environment profile. #2349

Closed

Description

@adityakiranpendyala

Description:

We have a profile property to connect to cloud config.(spring.cloud.config.profile)
with spring-cloud-config-client-4.0.4.jar, in class ConfigServicePropertySourceLocator, there is a new method which combines profile from property and environment with comma separated.
So, finally profile value while connecting to cloud config will be like below and failing cloud config call.

HTTP GET https://XXXXXXXXXX/cloud-config/properties//<PROFILE-XYX,ABC>/
This is failing.

Even though profile properties are overrider at line 122 ConfigClientProperties properties = this.defaultProperties.override(environment);

in the next line, profile value is getting updated by appending with all the profiles
properties.setProfile(String.join(",", combineProfiles(properties, environment)));

So in method getRemoteEnvironment, while preparing the URL, profile path param is goign as comma separated and there by causing issue.

Activity

  1. ryanjbaxter commented on Nov 7, 2023

    @ryanjbaxter
    Contributor

    Can you provide a complete, minimal, verifiable sample that reproduces the problem? It should be available as a GitHub (or similar) project or attached to this issue as a zip file.

  2. adityakiranpendyala commented on Nov 8, 2023

    @adityakiranpendyala
    Author

    Hi @ryanjbaxter ,

    I am preparing a sample with out exposing specific details.
    But issue gist is,

    1.Spring allows multiple profiles

    2.At line 116, properties.setProfile(String.join(",", combineProfiles(properties, environment)));
    profile can be comma separated.

    3.And we are sending this profile as a path parameter to a GET call at line 291
    response = restTemplate.exchange(uri + path, HttpMethod.GET, entity, Environment.class, args);

    where args is either = new String[] { name, profile }; or new String[] { name, profile, label };

    So, we are ending up having a comma separated URL in a Http GET call

    FILE: ConfigServicePropertySourceLocator.java

  3. adityakiranpendyala commented on Nov 9, 2023

    @adityakiranpendyala
    Author

    Hi @ryanjbaxter ,

    Here is an example. You can run below project as a Spring Boot application.

    1. I have one profile defined for logging.("logging-profile")
    2. I have properties to connect to spring cloud to download properties on startup.(config profile="CONFIG_PROFILE")
      So, I have two profiles, one at environment level and one for cloud profile.

    spring.cloud.config:
    name: CONFIG_NAME
    uri: http://localhost:8000/properties
    label: CONFIG_LABEL
    profile: CONFIG_PROFILE
    enabled: false
    failFast: true

    Now when I am starting application, I am getting URL as profiles with comma separated and failing.
    demo.zip

    GET request for "http://localhost:8888/CONFIG_NAME/CONFIG_PROFILE,logging-profile/CONFIG_LABEL

  4. changed the title [-]Version 4.0.4, unable to connect to App Config if we have app config profile and spring environment profile.[/-] [+]Version 4.0.4, unable to connect to Cloud Config if we have cloud config profile and spring environment profile.[/+] on Nov 9, 2023
  5. ryanjbaxter commented on Nov 15, 2023

    @ryanjbaxter
    Contributor

    I think I understand what you are saying now...

    If you set spring.cloud.config.profile it should override any profile(s) set in any other manor. So in your example if you set spring.cloud.config.profile=CONFIG_LABEL and set spring.profiles.active=logging-profile the request made to the config server should only have the CONFIG_LABEL profile, ie http://localhost:8888/CONFIG_NAME/CONFIG_PROFILE/CONFIG_LABEL. Is that correct?

  6. added a commit that references this issue on Nov 15, 2023
    923e4a0
  7. adityakiranpendyala commented on Nov 15, 2023

    @adityakiranpendyala
    Author
  8. added a commit that references this issue on Nov 15, 2023
    42c046f
  9. added this to the 4.0.5 milestone on Nov 21, 2023
  10. added a commit that references this issue on Nov 21, 2023
    861ed67
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions