keijack / python-eureka-client

A eureka client written in python. Support registering your python component to Eureka Server, as well as calling remote services by pulling the the Eureka registry.
MIT License
183 stars 43 forks source link

Bug - get_applications from eureka server registry #51

Closed dinuta closed 3 years ago

dinuta commented 3 years ago

Hi @keijack ,

I discovered a bug in the client discovery. Version 0.9.6. Probably this is not new.

Steps to reproduce:

  1. Spawn the environment from https://www.katacoda.com/dinuta/scenarios/estuary-discovery
  2. You will reach a step where eureka server is deployed and can be accessed via browser via a public address. The address has the form: https://2886795372-8080-frugo04.environments.katacoda.com/eureka/ Here you will see the services registered.
  3. List the apps from the eureka server registry: Example: https://2886795372-8080-frugo04.environments.katacoda.com/eureka/v2/apps. In the xml sent by eureka you will see 3 Agents.
  4. Get the same list with the eureka client implemented on your side which points to the public eureka address. The registration address has the form: https://2886795372-8080-frugo04.environments.katacoda.com/eureka/v2. It will only see just 1 Agent.

Expected behavior: The client sees 3 Agents and 1 discovery Actual result: The client sees 1 Agent and 1 discovery

Please have a look.

Thanks, Catalin

keijack commented 3 years ago

Thanks for submitting, I'll check it out later for the network connection now in my city is poor during this period.

dinuta commented 3 years ago

It seems like the InstanceId was '' for all the services. I saw you use this info in your code to uniquely identify the application. In this case your lib override the previous entry because of that.

If it does make sense to have InstanceId same (but think not) it is a bug, otherwise not.

This is the fix in the agent: https://github.com/estuaryoss/estuary-agent-go/pull/5/files

I let the environment replicate the bug if you still need to debug it.

Thanks, Catalin

dinuta commented 3 years ago

I closed the issue, thanks.

keijack commented 3 years ago

I think you should give each your instance an unique ID. However, it seems that sometimes the eureka server accepts the empty instance ids. I change some code, if the instance have no id get from eureka server, one will be generated via host name, ip address, app name and instance port. You can find the change in 0.9.7.