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

22nd
May 2018
Sergey Kryvets
@sergeome
May 22 2018 01:10
After intense fighting, trying to figure out what’s wrong I completely uninstalled java from my Mac. Performed fresh install. Everything works great right now. Wow. Embarassed to say that I should have done that first. Thanks a lot of your help.
arkin
@arkin
May 22 2018 02:09
Hi, is it possible to implement the bulkhead pattern with hystrix in Spring Cloud Gateway 2 via configuration? I used thread pool isolation in the past, but without threads the semaphore based approach seems to be the only option, which leaves timeout handling to lower layers.
vikrantch-hk
@vikrantch-hk
May 22 2018 07:13
@marcosbarbero is there a way to evict client from eureka server if it doesn't send heartbeat in a minute
nhmarujo
@nhmarujo
May 22 2018 08:46
Morning everyone. Is there a new date for the Finchley.RC2 release? thanks
Sushant
@bsushant-athena
May 22 2018 09:07
@marcosbarbero ,yes eureka.maxRetries is a valid config property! https://github.com/jquatier/eureka-js-client/blob/master/README.md
Marcos Barbero
@marcosbarbero
May 22 2018 09:31
@bsushant-athena I’m afraid that you are looking something that’s not supported.
This link above isn’t part of Netflix Eureka or Spring Cloud implementation.
Anyway, I’ll try to look further for this Config
Marcos Barbero
@marcosbarbero
May 22 2018 09:44
@vikrantch-hk did you check this spring-cloud/spring-cloud-netflix#202 ?
Shaoyong King
@collery
May 22 2018 09:59
Hello , ask a question . how to get ‘down’ instance from eureka.
i use filterOnlyUpInstances =false. but i can only get ‘down’ instances sometime. It refresh very very soon on eureka .
vikrantch-hk
@vikrantch-hk
May 22 2018 10:01
@marcosbarbero yes it is exactly same issue I facing but there is no solution mentioned in comments
Marcos Barbero
@marcosbarbero
May 22 2018 10:04
Do you have multiple eureka server instances? Did you play with the properties that sets time to do the heart beat?
vikrantch-hk
@vikrantch-hk
May 22 2018 10:06
yes we are running 2 eureka instances in peer aware fashion
using this property you can play with the registration/heartbeat time in seconds, also in this link you'll find out some recommendations for production
Marcos Barbero
@marcosbarbero
May 22 2018 10:24
@bsushant-athena check this https://cloud.spring.io/spring-cloud-static/spring-cloud.html#_appendix_compendium_of_configuration_properties, I can't find anything similar to this eureka.max-retries that you mentioned, I'm afraid that what you are looking at is something customized for this eureka-js-client.
CH4:D
@chad_d_stud_twitter
May 22 2018 11:06
sometimes some keys aren’t recognized or documented :-/
Marcos Barbero
@marcosbarbero
May 22 2018 11:09
It’s mentioned neither by spring cloud docs nor Netflix docs. That’s why I’m afraid it’s not really supported, although I can be wrong
If you google for it the very single place where this property is mentioned is this eureka-js-client and no where else.
Marcos Barbero
@marcosbarbero
May 22 2018 11:18
AFAIK there is no limit to the number of retries for registering with Eureka
Shaoyong King
@collery
May 22 2018 11:18
Anyone knows how to get down instances from eureka … if not ,i will ask again so
Marcos Barbero
@marcosbarbero
May 22 2018 11:19

What do you mean? Do you want to actually shutdown the instance or just set its status as down?

If you just shutdown the instance the heartbeat validation will do the job.

Shaoyong King
@collery
May 22 2018 11:23
I just want to know if there is an down instance on Eureka .then i can email to developer (poor English)
@Scheduled(cron = "0 0/1 * ? ")
public void active(){
    List<ServiceInstance> instances = discoveryClient.getInstances(instanceName);
    if (!CollectionUtils.isEmpty(instances)){
        for (ServiceInstance instance : instances) {
            InstanceInfo instanceInfo  =JSON.parseObject(JSON.toJSONString(JSON.parseObject(JSON.toJSONString(instance)).get("instanceInfo")),InstanceInfo.class);
                if (instanceInfo.getStatus().equals(InstanceInfo.InstanceStatus.DOWN)){

                    //if down send a email to developer
                }



        }
    }
}
Marcos Barbero
@marcosbarbero
May 22 2018 11:31

There are a plenty of tools for such monitoring, I wouldn’t recommend you to build it as you are trying to.

There are few things to take in consideration while doing that validation, if the instance is actually down (java process killed), it won’t be present in the list that you are trying to filter.
If there’s something wrong in one of its dependencies then it will be present with status down.

Shaoyong King
@collery
May 22 2018 11:40
ok .I try other options。 Thank you very much
Marcos Barbero
@marcosbarbero
May 22 2018 11:42
NP
Sushant
@bsushant-athena
May 22 2018 13:21
@marcosbarbero I've a java client which is using the eureka-client library and there also we set the eureka.properties in the config.
https://github.com/Netflix/eureka/wiki/Configuring-Eureka
Marcos Barbero
@marcosbarbero
May 22 2018 13:25
Sure.
My question still remains, is maxRetries a valid property? I don’t believe so, it’s not mentioned anywhere and that JS library is not an official library from Netflix
As I mentioned before
AFAIK there is no limit to the number of retries for registering with Eureka
Jose Armesto
@fiunchinho
May 22 2018 15:48

I have an spring cloud application that is using a private IP address that is not reachable by potential clients, so I'd like to register this application on Eureka using a public hostname, and make those services use that public hostname when sending http requests.
I've changed the app configuration, and now it's setting the eureka.instance.hostname property with the public hostname, and I make sure that preferIpAddress is false.

But now I see that clients are sometimes using the hostname , and sometimes the IP address (resulting on errors because it's not reachable).

What could be going on?

Marcos Barbero
@marcosbarbero
May 22 2018 15:50
I can only think about misconfiguration :worried:
Jose Armesto
@fiunchinho
May 22 2018 15:51
from the service itself?
this is what I have
eureka:
  instance:
    hostname: ${INGRESS_DNS}
    nonSecurePort: 80
    preferIpAddress: false
    instanceId: ${POD_NAME}
ingress dns is an env var containing a public dns that's reachable
Marcos Barbero
@marcosbarbero
May 22 2018 15:54
I’ve used eureka setup in a lot of ways and I’ve never faced such behavior. What’s the environment that you are deploying the apps? Any cloud? Private datacenter?
Jose Armesto
@fiunchinho
May 22 2018 15:56
we have some instances of the app running on AWS, and now we are migrating to kubernetes , so the IP address of the instances on kubernetes is not reachable from the outside, that's why I need to set a public hostname
so other apps still running on AWS can send http requests
Marcos Barbero
@marcosbarbero
May 22 2018 15:58
The API gateway is outside of kubernetes?
Jose Armesto
@fiunchinho
May 22 2018 15:59
you mean the one receiving traffic on the public dns? that's inside kubernetes
Marcos Barbero
@marcosbarbero
May 22 2018 16:02
And this one is redirecting to the eureka instances? I mean, eureka clients
Jose Armesto
@fiunchinho
May 22 2018 16:03
yes, it's acting like a proxy
but is not receiving the requests, becuase the clients are trying to send requests to the IP, instead of the hostname registered on eureka
image.png
zipkin is showing me this
it shouldn't be using the internal IP
Marcos Barbero
@marcosbarbero
May 22 2018 16:05
Remove zipkin, so you won’t see it anymore :trollface:
Jose Armesto
@fiunchinho
May 22 2018 16:06
hehe
so any ideas?
Marcos Barbero
@marcosbarbero
May 22 2018 16:06
Jokes apart, can you validade the INGRESS_DNS value? Maybe it’s wrong
Doesn’t kubernetes has a container to container communication using IPs? Maybe in different network adapters
Jose Armesto
@fiunchinho
May 22 2018 16:08
I can see the hostname value on Eureka, and it's fine
yeah but in this case the clients are not in kubernetes
Marcos Barbero
@marcosbarbero
May 22 2018 16:09
If you check the /eureka/apps endpoint do you have the right value?
Jose Armesto
@fiunchinho
May 22 2018 16:09
yeah, that's where I see it
Marcos Barbero
@marcosbarbero
May 22 2018 16:10
How are you doing your requests?
Jose Armesto
@fiunchinho
May 22 2018 16:11
using hystryx+feign+ribbon
Marcos Barbero
@marcosbarbero
May 22 2018 16:12
Any sample code to check?
Jose Armesto
@fiunchinho
May 22 2018 16:14
not really :( it's on the internal repository
but I don't know where to look, everything looks correct
Marcos Barbero
@marcosbarbero
May 22 2018 16:15
Well, seems to be correct to me as well
Doesn’t make a lot of sense to fetch hostname and IP as well
Jose Armesto
@fiunchinho
May 22 2018 16:18
if eureka contains always hostname and IP for registered services, how do clients know what to use?
Marcos Barbero
@marcosbarbero
May 22 2018 16:19
The preferIp flag says what to use
Jose Armesto
@fiunchinho
May 22 2018 16:21
I can't see that value in the info that Eureka keeps for the different services
so how does a client know what to use? because of its own preferIpAddress flag? I thought that was just for your requests not the requests from you to other services?
Marcos Barbero
@marcosbarbero
May 22 2018 16:24
It’s to the downstream service not for its own config.
If you are using ribbon, feign, discoveryClient, restTemplate using service names to load balance the requests, it will use this flag to know what to use to actually make the request
Jose Armesto
@fiunchinho
May 22 2018 16:25
so if service A has preferIpAddress set to true, all the requests to the service B and service C will use the IP address?
no matter what service B and service C have configured as preferIpAddress ?
Marcos Barbero
@marcosbarbero
May 22 2018 16:25
The other way around
That flag refers to the service itself not to what it’s calling
Using your example
Jose Armesto
@fiunchinho
May 22 2018 16:26
hence my question, how does service A what service B has configured as preferIpAddress if I can't see it on Eureka?
Marcos Barbero
@marcosbarbero
May 22 2018 16:27
ServiceA has preferIp to true and serviceB and C doesn’t. It will use the hostname to make a request
KaijuDeluxe
@KaijuDeluxe
May 22 2018 16:27
so another question., how can i configure the output for logging? I want that every service and also every instance of it, will have its own log file using systemd
Marcos Barbero
@marcosbarbero
May 22 2018 16:27
Are you using ribbon, feign, and so on, right?
Jose Armesto
@fiunchinho
May 22 2018 16:27
yes, hystrix+feign+ribbon
Marcos Barbero
@marcosbarbero
May 22 2018 16:28
It takes this value from eureka server itself
It’s there
lakshmipolu
@lakshmipolu
May 22 2018 16:29
Could anyone can share sample code to route post method with spring cloud gateway with two request parameters.
Jose Armesto
@fiunchinho
May 22 2018 16:30
this is what eureka responds
{
  "application": {
    "name": "myapp",
    "instance": [
      {
        "instanceId": "myapp-473740219-wmpbt",
        "hostName": "myapp.public-dns.com",
        "app": "myapp",
        "ipAddr": "172.17.10.41",
        "status": "UP",
        "overriddenstatus": "UNKNOWN",
        "port": {
          "$": 80,
          "@enabled": "true"
        },
        "securePort": {
          "$": 443,
          "@enabled": "false"
        },
        "countryId": 1,
        "dataCenterInfo": {
          "@class": "com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo",
          "name": "MyOwn"
        },
        "leaseInfo": {
          "renewalIntervalInSecs": 30,
          "durationInSecs": 90,
          "registrationTimestamp": 1526998052603,
          "lastRenewalTimestamp": 1527002824016,
          "evictionTimestamp": 0,
          "serviceUpTimestamp": 1526998052603
        },
        "metadata": {
          "@class": "java.util.Collections$EmptyMap"
        },
        "homePageUrl": "http://myapp.public-dns.com:80/",
        "statusPageUrl": "http://myapp.public-dns.com:80/info",
        "healthCheckUrl": "http://myapp.public-dns.com:80/health",
        "vipAddress": "myapp",
        "secureVipAddress": "myapp",
        "isCoordinatingDiscoveryServer": "false",
        "lastUpdatedTimestamp": "1526998052603",
        "lastDirtyTimestamp": "1526998052360",
        "actionType": "ADDED"
      }
    ]
  }
}
KaijuDeluxe
@KaijuDeluxe
May 22 2018 16:30
@lakshmipolu did you already set up the gateway service?
Jose Armesto
@fiunchinho
May 22 2018 16:31
I don't see the preferIpAddress value
Marcos Barbero
@marcosbarbero
May 22 2018 16:33
I can’t check the code right now to send it to you. But ribbon should know it
However, it raised me a question.
If you have the preferIpAddress to false, you have the hostname being set
Why is there still an IP address?
Jose Armesto
@fiunchinho
May 22 2018 16:34
you tell me :D
heheh
Marcos Barbero
@marcosbarbero
May 22 2018 16:35
Hahaha
Fair point hahaha
Jose Armesto
@fiunchinho
May 22 2018 16:35
I thought that ribbon was always using the hostname, and that setting preferIpAddress to true was making the eureka client to set the IP address as hostname too, forcing clients to use the IP (because it was the hostname as well)
lakshmipolu
@lakshmipolu
May 22 2018 16:35
yes I tested few API with get methods
Jose Armesto
@fiunchinho
May 22 2018 16:35
does that make sense?
lakshmipolu
@lakshmipolu
May 22 2018 16:35
but I'm looking for post
Marcos Barbero
@marcosbarbero
May 22 2018 16:36
It does
Jose Armesto
@fiunchinho
May 22 2018 16:36
so I didn't worry when I saw the IP address being set, I thought it would never be used
but aparently it does
Marcos Barbero
@marcosbarbero
May 22 2018 16:37
Well, let’s say you just set the IP address the same value as the hostname
What happens?
Jose Armesto
@fiunchinho
May 22 2018 16:38
I haven't tried that, but it feels like I'm doing it backwards (if my understanding of ribbon/eureka is correct)
Marcos Barbero
@marcosbarbero
May 22 2018 16:39
I would make it just in case.
Jose Armesto
@fiunchinho
May 22 2018 16:40
how would I go about it anyway?
Marcos Barbero
@marcosbarbero
May 22 2018 16:40
For now I’m not sure where the issue lies, it would validate it
There’s an eureka property to set the IP address
You can use it to set the same value as the hostname
Jose Armesto
@fiunchinho
May 22 2018 16:41
address ?
Marcos Barbero
@marcosbarbero
May 22 2018 16:41
I think it’s eureka.client.ip-address
Just set it the same ENV var that you have
If it solves the problem I’d rather file an issue explaining the whole thing
Jose Armesto
@fiunchinho
May 22 2018 16:43
can I set it on a running app? or do I have to change the code and re-deploy?
I'm not using Spring Config
Marcos Barbero
@marcosbarbero
May 22 2018 16:47
You can set it in the same way you are setting the hostname
It’s just one more property
Jose Armesto
@fiunchinho
May 22 2018 16:47
yeah, just wondering if I could PUT it to some endpoint
if I have to change it in the code, I need to open PR and re-deploy and so on
just curious
Marcos Barbero
@marcosbarbero
May 22 2018 16:52
I don’t believe you can make it by an endpoint
Most likely you can’t
lakshmipolu
@lakshmipolu
May 22 2018 17:14
Could anyone provide sample code for post method for SCG?