These are chat archives for spring-cloud/spring-cloud

20th
Jun 2018
Haruhiko Nishi
@hanishi
Jun 20 2018 01:33
@marcosbarbero
I found the problem.
In order to send characters like '{' '}' in the destination path I need to encode it somehow, but when these are encoded, the subscriber to the spring cloud bus seem to ignore it and therefore it refreshes regardless of destination parameter provided.
{ is valid character for a PathMatcher and I want to use it like
appname:{profile1|profile2}:**
maskleo
@maskleo
Jun 20 2018 01:42
hi,guys.I want to rebinding ConfigurationProperties data.Read user documentation.
post http://localhost:8080/env,It working .
But post http://localhost:8080/env/reset,Cannot refresh all configurations.
Can only refresh keys that have visited /env.
I want to refresh all the configuration what should I do?
Haruhiko Nishi
@hanishi
Jun 20 2018 03:07

@marcosbarbero
I used the following to build uri to be passed to RestTemplate

URI transfer = UriComponentsBuilder.fromUriString("http://euler-httpclient-processor-kafka/management/bus/refresh")
                    .queryParam("destination", "euler-httpclient-processor-kafka:transfer:**")
                    .build(false).toUri();

and I see requests are created as expected.

2018-06-20 12:03:00.015 DEBUG [service-edge,,,] 31157 --- [ryBean_Worker-1] o.s.web.client.RestTemplate              : Created POST request for "http://euler-httpclient-processor-kafka/management/bus/refresh?destination=euler-httpclient-processor-kafka:transfer:**"
2018-06-20 12:03:00.016 DEBUG [service-edge,,,] 31157 --- [ryBean_Worker-1] o.s.web.client.RestTemplate              : Setting request Accept header to [application/json, application/*+json]
2018-06-20 12:03:00.873 DEBUG [service-edge,8e9db5ccf7852878,8e9db5ccf7852878,false] 31157 --- [ryBean_Worker-1] o.s.web.client.RestTemplate              : POST request for "http://euler-httpclient-processor-kafka/management/bus/refresh?destination=euler-httpclient-processor-kafka:transfer:**" resulted in 200 (null)
2018-06-20 12:03:00.874 DEBUG [service-edge,,,] 31157 --- [ryBean_Worker-1] o.s.web.client.RestTemplate              : Created POST request for "http://euler-httpclient-processor-kafka/management/bus/refresh?destination=euler-httpclient-processor-kafka:machinist:**"
2018-06-20 12:03:00.874 DEBUG [service-edge,,,] 31157 --- [ryBean_Worker-1] o.s.web.client.RestTemplate              : Setting request Accept header to [application/json, application/*+json]
2018-06-20 12:03:01.814 DEBUG [service-edge,c170f893a0679eb6,c170f893a0679eb6,false] 31157 --- [ryBean_Worker-1] o.s.web.client.RestTemplate              : POST request for "http://euler-httpclient-processor-kafka/management/bus/refresh?destination=euler-httpclient-processor-kafka:machinist:**" resulted in 200 (null)
2018-06-20 12:03:01.814 DEBUG [service-edge,,,] 31157 --- [ryBean_Worker-1] o.s.web.client.RestTemplate              : Created POST request for "http://euler-cookiecutter-processor-kafka/management/bus/refresh?destination=euler-cookiecutter-processor-kafka:**"
2018-06-20 12:03:01.814 DEBUG [service-edge,,,] 31157 --- [ryBean_Worker-1] o.s.web.client.RestTemplate              : Setting request Accept header to [application/json, application/*+json]
2018-06-20 12:03:02.539 DEBUG [service-edge,1d535d6b1969eb81,1d535d6b1969eb81,false] 31157 --- [ryBean_Worker-1] o.s.web.client.RestTemplate              : POST request for "http://euler-cookiecutter-processor-kafka/management/bus/refresh?destination=euler-cookiecutter-processor-kafka:**" resulted in 200 (null)

However, destination is still ignored.
Interestingly same operation performed by curl works.

Difference is that I pick one instance to which request is made such as

curl  -X POST http://adpt1.euler:45578/management/bus/refresh?destination=euler-httpclient-processor-kafka:transfer:**

But with RestTemplate I let the Ribbon client pick one

Marcos Barbero
@marcosbarbero
Jun 20 2018 07:13
@maskleo search for refresh endpoint, that's the one you need
Hello @hanishi, good morning.
That's indeed something a little off, not to say weird, I would expect that using the UriComponentsBuilder would solve the problem.
Haruhiko Nishi
@hanishi
Jun 20 2018 07:42

Conclusion: What I have described above is irrelevant. Behavior described in 5 below is what made me go nuts.

Here is what happend:

  1. Spring Cloud Bus subscribers ignores destination param if POST request is targeted itself and refresh is performed regardless of the path provided to the destination
  2. I have 3 apps and they all have same spring.application.name which is default value for the Eureka's vip.
  3. These 3 apps are however launched with different profiles. Say, profile 'A', 'B', 'C'
  4. When refresh is performed, Ribbon client chooses one instance from those 3 apps.
  5. If Ribbon have picked the instance with profile 'A' and the refresh is performed with 'destination=B' then 'A' and 'B' will be refreshed. If Ribbon have picked the instance with profile 'C' and the refresh is performed with 'destination=B' then 'C' and 'B' will be refreshed.
    and this is what was confusing and took me so long why it was happening.
    Isn't the behavior described in 5. little strange and 1. is what I think needs some fix? or is this intended?
maskleo
@maskleo
Jun 20 2018 07:45
@marcosbarbero I just want to refresh the configuration.Will you refresh all the beans? That will be a big operation.
Marcos Barbero
@marcosbarbero
Jun 20 2018 07:47
@hanishi i'm a little confused :smile: I'll need to read it once more
@maskleo it will refresh only what needs to be refreshed, everything else remains the same
Haruhiko Nishi
@hanishi
Jun 20 2018 07:51
@marcosbarbero
I don't know why so but 1. that I described leads to confusion if you have same apps launched with different profiles and you just want to refresh one with a specific profile.
Marcos Barbero
@marcosbarbero
Jun 20 2018 07:53
I don't think it works that way, AFAIK it doesn't differ per profile only per application.name, once you push the bus refresh it will update everything that has the same name
maskleo
@maskleo
Jun 20 2018 07:53
@marcosbarbero Thanks for you reply. I will try to do that.
Marcos Barbero
@marcosbarbero
Jun 20 2018 07:53
If I'm not mistaken you also need to make sure that each app has a difference instance_id, otherwise it won't know which instance to update
np @maskleo
maskleo
@maskleo
Jun 20 2018 07:56
ok
Haruhiko Nishi
@hanishi
Jun 20 2018 07:57
If you pass destinaiton=appname:profile:\*\* then you can target one with specific instance that matches the path. I think you could include instanceId in it? I am not sure though.
Although instance_id can be just some arbitrary UUID generated by container that launched the app so may not be useful.
Enrico Hofmann
@gigo1980_gitlab
Jun 20 2018 07:58
hi together in the roadmap of spring-cloud version https://github.com/spring-cloud/spring-cloud-release/milestone/55 the Finchley.RELEASE should be still released :), is there any schedule?
Marcos Barbero
@marcosbarbero
Jun 20 2018 08:21
@gigo1980_gitlab it was released yesterday
@hanishi does that work? this appname:profile thing?
Marcos Barbero
@marcosbarbero
Jun 20 2018 08:26
good one!
Haruhiko Nishi
@hanishi
Jun 20 2018 08:26
I also looked into the source code and this is where profile is handled.
ContextIdApplicationContextInitializer
 private String getApplicationId(ConfigurableEnvironment environment) {
        String name = environment.resolvePlaceholders(this.name);
        String index = environment.resolvePlaceholders("${vcap.application.instance_index:${spring.application.index:${server.port:${PORT:null}}}}");
        String profiles = StringUtils.arrayToCommaDelimitedString(environment.getActiveProfiles());
        if (StringUtils.hasText(profiles)) {
            name = name + ":" + profiles;
        }

        if (!"null".equals(index)) {
            name = name + ":" + index;
        }

        return name;
    }
Marcos Barbero
@marcosbarbero
Jun 20 2018 08:29
yeah, now I recall it. I've seen this piece of code before
Haruhiko Nishi
@hanishi
Jun 20 2018 08:30
But still the behavior described in 5. above is confusing
Marcos Barbero
@marcosbarbero
Jun 20 2018 08:32
let's talk about your solution design just to get a better picture
this bus/trigger that you created, is it within the same application that you are triggering the /bus/refresh?
Haruhiko Nishi
@hanishi
Jun 20 2018 08:35
Yes. they are all same application.
What made my confused is when one of those instance happen to be chosen by client load balancer is the one the POST request is sent to, then the instance is refreshed regardless of the destination path provided in the URI.
Marcos Barbero
@marcosbarbero
Jun 20 2018 08:37
what if you use the configserver as the application to trigger the /bus/refresh?
Haruhiko Nishi
@hanishi
Jun 20 2018 08:41
That could be an option, if it propagates to all instances subscribed to the bus.
I have to make my config server discoverable though
Marcos Barbero
@marcosbarbero
Jun 20 2018 08:52
how are you pointing to your configserver now? I mean, all the apps in the boostrap.yml
is it an static URL?
Haruhiko Nishi
@hanishi
Jun 20 2018 08:54
Yep, with spring.cloud.config.uri but that just made me think I am using it wrong lol
Marcos Barbero
@marcosbarbero
Jun 20 2018 08:55
that's not wrong though
Haruhiko Nishi
@hanishi
Jun 20 2018 08:55
I could just pull it from Eureka haha...
Marcos Barbero
@marcosbarbero
Jun 20 2018 08:57
you can use configserverusing two approaches
  1. Eureka/Consul discoverable
  2. Static location, maybe a cluster using any load-balancer on top as this application doesn't really need to be that elastic and discoverable
if you have a static location something like https://configserver.company.net you can do your request using this fixed host instead discover a particular instance
Enrico Hofmann
@gigo1980_gitlab
Jun 20 2018 09:20
@marcosbarbero: So the website http://projects.spring.io/spring-cloud/ just needs to be updated to make sure the version Finchley has already been released.
Marcos Barbero
@marcosbarbero
Jun 20 2018 09:22
it will, one step at a time :smile: it was released late yesterday, there's for sure someone working on this update while we talk
Enrico Hofmann
@gigo1980_gitlab
Jun 20 2018 09:23
ok perfect, nice to know
Ryan Dawson
@ryandawsonuk
Jun 20 2018 10:00
has anyone managed to get spring cloud gateway working with services that use hateoas? I see that spring-cloud/spring-cloud-gateway#314 is open. In that case @RobMaskell seems to have managed to work around it by adding the header himself with a "- AddRequestHeader=x-forwarded-prefix, /api" filter. But in my case I am using discovery locator so I don't have a fixed value to add
maybe I could try overriding that bean in my project and adding it locally
Fethullah Misir
@fmisir
Jun 20 2018 10:37

Hi all, i upgraded from spring cloud connectors 2.0.1.RELEASE to 2.0.2.RELEASE and got login failures with a oracle database.
The problem is that in 2.0.2 the password and username is URL Encoded, thus the login fails when the password/username contains special characters like for my case a bracket ']'.
The encoding is done only for Oracle.
https://github.com/spring-cloud/spring-cloud-connectors/blob/2.0.2.RELEASE/spring-cloud-core/src/main/java/org/springframework/cloud/service/common/OracleServiceInfo.java
https://github.com/spring-cloud/spring-cloud-connectors/blob/2.0.1.RELEASE/spring-cloud-core/src/main/java/org/springframework/cloud/service/common/OracleServiceInfo.java
Is there any reason why username and password are going to be url encoded for building the JDBC URL? And is there a workaround for this "issue"? Thx!

Can anyone can help me out with this?