Fabriceli commented on code in PR #8928:
URL: https://github.com/apache/apisix/pull/8928#discussion_r1116400916


##########
apisix/discovery/consul/init.lua:
##########
@@ -215,14 +215,38 @@ function _M.connect(premature, consul_server, retry_delay)
 
     -- if current index different last index then update service
     if consul_server.index ~= watch_result.headers['X-Consul-Index'] then
-        local up_services = core.table.new(0, #watch_result.body)
+
+        local consul_client_catalog = resty_consul:new({
+            host = consul_server.host,
+            port = consul_server.port,
+            connect_timeout = consul_server.connect_timeout,
+            read_timeout = consul_server.read_timeout,
+        })
+
+        local catalog_result, catalog_err = 
consul_client_catalog:get(consul_server.consul_catalog_sub_url)
+        local catalog_error_info = (catalog_err ~= nil and catalog_err)
+                or ((catalog_result ~= nil and catalog_result.status ~= 200)
+                and catalog_result.status)
+        if catalog_error_info then
+            log.error("connect consul: ", consul_server.consul_server_url,
+                " by sub url: ", consul_server.consul_catalog_sub_url,
+                ", got watch result: ", json_delay_encode(catalog_result, 
true),
+                ", with error: ", catalog_error_info)
+            -- retry_delay = get_retry_delay(retry_delay)

Review Comment:
   The commented code should be removed. if it should be kept, please give the 
reason and put the reason in the comment



##########
apisix/discovery/consul/init.lua:
##########
@@ -246,7 +270,7 @@ function _M.connect(premature, consul_server, retry_delay)
                 -- add services to table
                 local nodes = up_services[service_name]
                 for  _, node in ipairs(result.body) do
-                    local svc_address, svc_port = node.ServiceAddress, 
node.ServicePort
+                    local svc_address, svc_port = node.Service.Address, 
node.Service.Port

Review Comment:
   need to check whether `node.Service` is nil



-- 
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]

Reply via email to