Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tencent-cloud-cls): DNS parsing failure #9843

Merged
merged 6 commits into from
Aug 17, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions apisix/plugins/tencent-cloud-cls/cls-sdk.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original code used socket.dns.topip, I didn't modify it. What is the difference between these two methods?

Copy link
Contributor

@monkeyDluffy6017 monkeyDluffy6017 Jul 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could check the logic between the two functions, we always use parse_domain, maybe it will resolve the problem of the socket.dns.toip occasionally returns nil

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems can't resolve this problem.

#   Failed test 't/plugin/tencent-cloud-cls.t TEST 10: log use log_format - pattern "[error]" should not match any line in error.log but matches line "2023/07/18 21:16:48 [error] 28051\#33045887: *50 [lua] resolver.lua:80: parse_domain(): failed to parse domain: jiangfuchengdeMacBook-Pro.local, error: failed to query the DNS server: dns server error: 3 name error, context: ngx.timer, client: 127.0.0.1, server: 0.0.0.0:1984" (req 0)

If we can't merge this temporary fix, I will investigate the reasons for the failure.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pr is ok, but we need to know the reason

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Sn0rt Ok, give me some time to test it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jiangfucheng do you have any update for this ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, there is currently no conclusion yet.

-- DNS parsing failure
local err = resolved
core.log.warn("resolve ip failed, hostname: " .. hostname .. ", error: " .. err)
jiangfucheng marked this conversation as resolved.
Show resolved Hide resolved
insert_tab(ip_list, "127.0.0.1")
monkeyDluffy6017 marked this conversation as resolved.
Show resolved Hide resolved
else
for _, v in ipairs(resolved.ip) do
insert_tab(ip_list, v)
end
end
return ip_list
end
Expand Down