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

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

Closed
adityakiranpendyala opened this issue Nov 7, 2023 · 5 comments · Fixed by #2354
Labels
Milestone

Comments

@adityakiranpendyala
Copy link

adityakiranpendyala commented Nov 7, 2023

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.

@ryanjbaxter
Copy link
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.

@adityakiranpendyala
Copy link
Author

adityakiranpendyala commented Nov 8, 2023

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

@adityakiranpendyala
Copy link
Author

adityakiranpendyala commented Nov 9, 2023

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

@adityakiranpendyala adityakiranpendyala 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. Nov 9, 2023
@ryanjbaxter
Copy link
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?

@adityakiranpendyala
Copy link
Author

yes @ryanjbaxter , your understanding is correct.
Config Service URL should be http://localhost:8888/CONFIG_NAME/CONFIG_PROFILE/CONFIG_LABEL
but now it is preparing as http://localhost:8888/CONFIG_NAME/CONFIG_PROFILE,logging-profile/CONFIG_LABEL

ryanjbaxter added a commit to ryanjbaxter/spring-cloud-config that referenced this issue Nov 15, 2023
Fixes spring-cloud#2349

Revert "Make method clearer"

This reverts commit fda8596568fb035d8c7839eeef6edaae712b427f.

Make method clearer
@ryanjbaxter ryanjbaxter added this to the 4.0.5 milestone Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants