jiangfucheng commented on code in PR #9843:
URL: https://github.com/apache/apisix/pull/9843#discussion_r1287123805


##########
apisix/plugins/tencent-cloud-cls/cls-sdk.lua:
##########
@@ -62,8 +62,15 @@ local params_cache = {
 local function get_ip(hostname)
     local _, resolved = socket.dns.toip(hostname)
     local ip_list = {}
-    for _, v in ipairs(resolved.ip) do
-        insert_tab(ip_list, v)
+    if not resolved.ip then
+        -- DNS parsing failure
+        local err = resolved
+        core.log.warn("resolve ip failed, hostname: " .. hostname .. ", error: 
" .. err)
+        insert_tab(ip_list, "127.0.0.1")

Review Comment:
   Just want to set a default value to avoid init failure. I moved the init ip 
logic to `send_cls_request` function now, we can return error directly instead 
of setting the default value.



##########
apisix/plugins/tencent-cloud-cls/cls-sdk.lua:
##########
@@ -62,8 +62,15 @@ local params_cache = {
 local function get_ip(hostname)
     local _, resolved = socket.dns.toip(hostname)
     local ip_list = {}
-    for _, v in ipairs(resolved.ip) do
-        insert_tab(ip_list, v)
+    if not resolved.ip then
+        -- DNS parsing failure
+        local err = resolved
+        core.log.warn("resolve ip failed, hostname: " .. hostname .. ", error: 
" .. err)

Review Comment:
   updated, 



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