tzssangglass commented on issue #5767: URL: https://github.com/apache/apisix/issues/5767#issuecomment-1000697148
I followed your way and could not reproduce. Here are the steps I took to reproduce it #### step 1 start Nacos 2.0.1 as satndalone(get from https://github.com/alibaba/nacos/releases/tag/2.0.1) #### step 2 start [service provider](https://github.com/nacos-group/nacos-examples/tree/master/nacos-spring-cloud-example/nacos-spring-cloud-discovery-example/nacos-spring-cloud-provider-example) and register service to Nacos. and test get service from Nacos ```shell curl -X GET '127.0.0.1:8848/nacos/v1/ns/instance/list?healthyOnly=true&serviceName=service-provider' {"name":"DEFAULT_GROUP@@service-provider","groupName":"DEFAULT_GROUP","clusters":"","cacheMillis":10000,"hosts":[{"instanceId":"192.168.2.43#8070#DEFAULT#DEFAULT_GROUP@@service-provider","ip":"192.168.2.43","port":8070,"weight":1.0,"healthy":true,"enabled":true,"ephemeral":true,"clusterName":"DEFAULT","serviceName":"DEFAULT_GROUP@@service-provider","metadata":{"preserved.register.source":"SPRING_CLOUD"},"instanceHeartBeatInterval":5000,"instanceHeartBeatTimeOut":15000,"ipDeleteTimeout":30000}],"lastRefTime":1640330295589,"checksum":"","allIPs":false,"reachProtectionThreshold":false,"valid":true} ``` #### step 3 my route config is ```json { "uri": "/*", "upstream": { "type": "roundrobin", "hash_on": "vars", "scheme": "http", "discovery_type": "nacos", "pass_host": "pass", "service_name": "service-provider" }, "status": 1 } ``` my config.yaml is ```yaml apisix: admin_key: - name: admin key: edd1c9f034335f136f87ad84b625c8f1 # using fixed API token has security risk, please update it when you deploy to production environment role: admin discovery: nacos: host: - "http://127.0.0.1:8848" ``` #### step 4 ```diff diff --git a/apisix/discovery/nacos/init.lua b/apisix/discovery/nacos/init.lua index d163b395..9624349d 100644 --- a/apisix/discovery/nacos/init.lua +++ b/apisix/discovery/nacos/init.lua @@ -225,6 +225,7 @@ local function get_nacos_services() iter_and_add_service(services, values) values = get_services() iter_and_add_service(services, values) + ngx.log(ngx.WARN, "services : ", require("lualib.inspect")(services)) return services end diff --git a/apisix/upstream.lua b/apisix/upstream.lua index 4e23fbff..47f83e1b 100644 --- a/apisix/upstream.lua +++ b/apisix/upstream.lua @@ -244,6 +244,7 @@ function _M.set_by_route(route, api_ctx) end local new_nodes, err = dis.nodes(up_conf.service_name, up_conf.discovery_args) + ngx.log(ngx.WARN, "new_nodes : ", require("lualib.inspect")(new_nodes)) if not new_nodes then return HTTP_CODE_UPSTREAM_UNAVAILABLE, "no valid upstream node: " .. (err or "nil") end diff --git a/conf/config.yaml b/conf/config.yaml index 421ac091..8e5d7764 100644 --- a/conf/config.yaml +++ b/conf/config.yaml @@ -45,3 +45,7 @@ apisix: - name: admin key: edd1c9f034335f136f87ad84b625c8f1 # using fixed API token has security risk, please update it when you deploy to production environment role: admin +discovery: + nacos: + host: + - "http://127.0.0.1:8848" ``` and my error.log is ``` 2021/12/24 15:14:29 [warn] 20348#10949645: *19 [lua] init.lua:228: get_nacos_services(): services : { { group_name = "DEFAULT_GROUP", namespace_id = "public", service_name = "service-provider" } }, context: ngx.timer 2021/12/24 15:14:29 [warn] 20359#10949656: *13 [lua] plugin.lua:222: load_stream(): new plugins: {"ip-restriction":true,"mqtt-proxy":true,"limit-conn":true}, context: init_worker_by_lua* 2021/12/24 15:14:29 [warn] 20350#10949647: *2 [lua] plugin.lua:222: load_stream(): new plugins: {"ip-restriction":true,"mqtt-proxy":true,"limit-conn":true}, context: init_worker_by_lua* 2021/12/24 15:14:29 [warn] 20351#10949648: *4 [lua] plugin.lua:222: load_stream(): new plugins: {"ip-restriction":true,"mqtt-proxy":true,"limit-conn":true}, context: init_worker_by_lua* 2021/12/24 15:14:30 [warn] 20348#10949645: *637 [lua] upstream.lua:247: set_upstream(): new_nodes : { { host = "192.168.2.43", port = 8070, weight = 1 } }, client: 127.0.0.1, server: _, request: "GET /echo/hello HTTP/1.1", host: "127.0.0.1:9080" ``` I didn't reproduce the bug you mentioned, is there any difference between our previous steps? Note: I used https://github.com/nacos-group/nacos-examples/tree/master/nacos-spring-cloud-example/nacos-spring-cloud-discovery-example/nacos-spring-cloud-provider-example as java service to register to Nacos. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
