hydra-router icon indicating copy to clipboard operation
hydra-router copied to clipboard

hydra-router require guarantee of running node during route match

Open jkyberneees opened this issue 7 years ago • 8 comments

The router seems to be accepting the first URL match without guarantee that such service have a running node instance. In my case I just started a hapi-service-test service and the response from the router is this:

{
 "statusCode": 503,
 "statusMessage": "Service Unavailable",
 "statusDescription": "The server is currently unable to handle the request due to a temporary overloading or maintenance of the server. The implication is that this is a temporary condition which will be alleviated after some delay",
 "result": {
   "reason": "HR: [ol0r2s8oml] Unavailable express-service-test instances"
 },
 "tracer": "ol0r2s8oml"
}

Meaning that the hydra-router is considering old routes from the express-service-test service that I have ran in the past.

Regards, Rolando

jkyberneees avatar Apr 19 '17 07:04 jkyberneees

@jkyberneees on startup, your hapi-service-test should have sent a message to hydra-router with its updated routes.

cjus avatar Apr 19 '17 16:04 cjus

Hi @cjus, it does it. However the issue appears when multiple services have registered the same route. IMO the router should decide for the service that match the route but also is online.

jkyberneees avatar Apr 19 '17 17:04 jkyberneees

@jkyberneees I looked into this. I don't see a way to address it. I think it's up to the service builder to ensure that routes are not reused by other services. Meaning two different services should not both register v1/{serviceName}/endpoint. I also think that service registries have to expire at some point. Perhaps a router that ends up with a 503 might flush the service registry or perhaps a Lua script in Redis.

cjus avatar Apr 27 '17 23:04 cjus

Hi @cjus, I can suggest you to check for service presence before accept the route match. You can see an example here: https://github.com/jkyberneees/hydra-plugin-http/blob/master/libs/proxy.js#L35 I agree on the flush of the routes if 503 is detected, that would keep the router more performant and consistent.

Regards.

jkyberneees avatar Apr 28 '17 07:04 jkyberneees

Hello This discussion is old, but I have the same issue with hydra-router.

I used the different command for clean and refresh: hydra-cli refresh hydra-cli refresh node list

but hydra-cli routes show me the old dead services and then hydra-router cannot work correctly.

Is it something I am missing for cleaning/refresh ?

arn-the-long-beard avatar Mar 06 '18 09:03 arn-the-long-beard

@arn-the-long-beard which version of hydra-cli are you using? How comfortable are you with Redis? Is this happening locally or on a production server?

cjus avatar Mar 06 '18 12:03 cjus

Hello @cjus :)

I am using [email protected]

For now this is happening locally. I am a very newbie to Hydra and Redis also. I am building micro services for a distributed system for the startup I am working.

arn-the-long-beard avatar Mar 06 '18 15:03 arn-the-long-beard

Same problem here. I'm using [email protected]

hydra-cli refresh and hydra-cli refresh node listkeeps old routes, is not cleaning properly

emirhg avatar Nov 05 '19 04:11 emirhg