apisix icon indicating copy to clipboard operation
apisix copied to clipboard

bug: discovery Eureka cannot automatically proxy to a new node

Open Hmemories opened this issue 6 years ago • 10 comments

Issue description

register a new instance to Eureka,but can't proxy to this instance

Environment

  • apisix version (cmd: apisix version): 1.4
  • OS:mac os

Minimal test code / Steps to reproduce the issue

1. 2. 3.

What's the actual result? (including assertion message & call stack if applicable)

oldnode host":"172.16.50.93","port":8888 newnode host":"172.16.50.93","port":8081 apisix balance proxy to oldnode not to newnode after make reload it‘s OK

What's the expected result?

Hmemories avatar Jul 13 '20 10:07 Hmemories

please make a try with this PR: https://github.com/apache/incubator-apisix/pull/1835/files

I think this PR should fix this bug.

membphis avatar Jul 13 '20 10:07 membphis

image I tried with this PR and copied the code that different from main to my own branch ,but it always proxy to old

Hmemories avatar Jul 14 '20 02:07 Hmemories

2020/07/14 10:37:02 [info] 60274#3150962: 173669 [lua] balancer.lua:193: pick_server(): [{"host":"172.16.50.93","port":8889,"metadata":{"management.port":"8889","commit-time":"2019-08-27T14:48:42+0800","git-short-commitid":"11efbdd","commit-branch":"dev","jar-version":"0.10.2","msv-version":"1.7.2","commit-message":"Merge branch 'apollo-generator' into 'dev'","git-commitid":"11efbdd805134d9e5ff7a0cd41aea0f6241c9602"},"weight":100},{"host":"172.16.50.93","port":8081,"metadata":{"management.port":"8081"},"weight":100}] while connecting to upstream, client: ::1, server: , request: "GET /atel/all/cmdb/apps HTTP/1.1", host: "localhost:9080" 2020/07/14 10:37:02 [info] 60274#3150962: 173669 [lua] balancer.lua:239: pick_server(): ctx: {"plugins":[{"priority":1008,"version":0.1,"schema":{"properties":{"regex_uri":{"maxItems":2,"description":"new uri that substitute from client uri for upstream, lower priority than uri property","items":{"description":"regex uri","type":"string"},"minItems":2,"type":"array"},"uri":{"maxLength":4096,"pattern":"\/.","minLength":1,"description":"new uri for upstream","type":"string"},"scheme":{"type":"string","enum":["http","https"],"description":"new scheme for upstream"},"host":{"type":"string","pattern":"[0-9a-zA-Z-.]+$","description":"new host for upstream"},"headers":{"type":"object","minProperties":1,"description":"new headers for request"}},"type":"object","minProperties":1},"check_schema":"function: 0x17ec5e38","name":"proxy-rewrite","rewrite":"function: 0x17ec6050"},"table: 0x1808d110"],"conf_id":"1","conf_type":"route","conf_version":140,"var":{"host":"localhost","request_method":"GET","uri":"/atel/all/cmdb/apps","remote_addr":"::1","upstream_uri":"/cmdb/apps","is_args":"","_request":"cdata: 0x7f8e2d801a50"},"balancer_name":"default","matched_route":{"value":{"priority":0,"plugins":{"proxy-rewrite":{"regex_uri":["/atel/all/(.)","/$1"]}},"uri":"/atel/","id":"1","upstream":{"service_name":"ATEL-CORE-MSV","hash_on":"vars","nodes":[{"host":"172.16.50.93","port":8889,"metadata":{"msv-version":"1.7.2","jar-version":"0.10.2","management.port":"8889","commit-time":"2019-08-27T14:48:42+0800","git-short-commitid":"11efbdd","commit-message":"Merge branch 'apollo-generator' into 'dev'","commit-branch":"dev","git-commitid":"11efbdd805134d9e5ff7a0cd41aea0f6241c9602"},"weight":100},{"host":"172.16.50.93","port":8081,"metadata":{"management.port":"8081"},"weight":100}],"type":"roundrobin"}},"clean_handlers":{},"createdIndex":140,"has_domain":false,"key":"/apisix/routes/1","modifiedIndex":140},"balancer_try_count":1} while connecting to upstream, client: ::1, server: , request: "GET /atel/all/cmdb/apps HTTP/1.1", host: "localhost:9080" 2020/07/14 10:37:02 [info] 60274#3150962: *173669 [lua] balancer.lua:240: pick_server(): server: "172.16.50.93:8083" while connecting to upstream, client: ::1, server: , request: "GET /atel/all/cmdb/apps HTTP/1.1", host: "localhost:9080"

Hmemories avatar Jul 14 '20 02:07 Hmemories

@qiujiayu do you have time to take a look at this bug?

membphis avatar Jul 14 '20 03:07 membphis

@qiujiayu do you have time to take a look at this bug? Is this problem solved now?

Hmemories avatar Jul 28 '20 14:07 Hmemories

@membphis Is this problem solved now?

Hmemories avatar Oct 21 '20 08:10 Hmemories

@qiujiayu do you have time to fix this issue?

@Hmemories I think this bug has not been fixed. would like to fix it by yourself?

we can support Eureka in plugin, set the upstream node by this way: https://github.com/apache/apisix/blob/master/apisix/plugins/example-plugin.lua#L91

it should be a new way which is simpler.

membphis avatar Oct 21 '20 09:10 membphis

I have an idea to solve this problem,do you think it's feasible? image

Hmemories avatar Nov 11 '20 03:11 Hmemories

ping @membphis

juzhiyuan avatar Nov 12 '20 15:11 juzhiyuan

it seems fine, welcome PR

membphis avatar Nov 18 '20 09:11 membphis