Skip to content

Commit

Permalink
fix(dns): change dns client switch to new_dns_client (#13501)
Browse files Browse the repository at this point in the history
* fix(dns): change dns client switch to `new_dns_client`

* fixed test case failures

* remove unnecessary debug log

* fixed test cases

* fix test cases: revert 05 worker_consistency

* fixed dns tool switch
  • Loading branch information
chobits authored Aug 16, 2024
1 parent 64a0dd1 commit ca9c4ea
Show file tree
Hide file tree
Showing 18 changed files with 257 additions and 183 deletions.
4 changes: 1 addition & 3 deletions kong.conf.default
Original file line number Diff line number Diff line change
Expand Up @@ -1542,9 +1542,7 @@
# It provides observable statistics, you can retrieve them through the Admin API
# `/status/dns`.

#legacy_dns_client = off # Disable the new DNS resolver, using the
# original DNS resolver. See above `dns_xxx`
# options for the original DNS resolver.
#new_dns_client = on # Enable the new DNS resolver

#resolver_address = <name servers parsed from resolv.conf>
# Comma-separated list of nameservers, each
Expand Down
2 changes: 1 addition & 1 deletion kong/api/routes/dns.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ return {
["/status/dns"] = {
GET = function (self, db, helpers)

if kong.configuration.legacy_dns_client then
if not kong.configuration.new_dns_client then
return kong.response.exit(501, {
message = "not implemented with the legacy DNS client"
})
Expand Down
2 changes: 1 addition & 1 deletion kong/api/routes/kong.lua
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ return {
},
["/status/dns"] = {
GET = function (self, db, helpers)
if kong.configuration.legacy_dns_client then
if not kong.configuration.new_dns_client then
return kong.response.exit(501, { message = "not implemented with the legacy DNS client" })
end

Expand Down
2 changes: 1 addition & 1 deletion kong/conf_loader/constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ local CONF_PARSERS = {
dns_error_ttl = { typ = "number" },
dns_no_sync = { typ = "boolean" },

legacy_dns_client = { typ = "boolean" },
new_dns_client = { typ = "boolean" },

resolver_address = { typ = "array" },
resolver_hosts_file = { typ = "string" },
Expand Down
4 changes: 2 additions & 2 deletions kong/resty/dns/client.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- Use the new dns client library instead. If you want to switch to the original
-- one, you can set `legacy_dns_client = on` in kong.conf.
if ngx.shared.kong_dns_cache and not _G.busted_legacy_dns_client then
-- one, you can set `new_dns_client = off` in kong.conf.
if ngx.shared.kong_dns_cache and _G.busted_new_dns_client ~= false then
package.loaded["kong.dns.client"] = nil
return require("kong.dns.client")
end
Expand Down
2 changes: 1 addition & 1 deletion kong/templates/kong_defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ dns_not_found_ttl = 30
dns_error_ttl = 1
dns_no_sync = off
legacy_dns_client = off
new_dns_client = on
resolver_address = NONE
resolver_hosts_file = /etc/hosts
Expand Down
2 changes: 1 addition & 1 deletion kong/templates/nginx_kong.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ lua_shared_dict kong_db_cache ${{MEM_CACHE_SIZE}};
lua_shared_dict kong_db_cache_miss 12m;
lua_shared_dict kong_secrets 5m;
> if not legacy_dns_client then
> if new_dns_client then
lua_shared_dict kong_dns_cache ${{RESOLVER_MEM_CACHE_SIZE}};
> end
Expand Down
2 changes: 1 addition & 1 deletion kong/tools/dns.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ local setup_client = function(conf)
}

-- new dns client
if ngx.shared.kong_dns_cache and not _G.busted_legacy_dns_client then
if ngx.shared.kong_dns_cache and _G.busted_new_dns_client ~= false then

servers = {}

Expand Down
Loading

1 comment on commit ca9c4ea

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

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

Bazel Build

Docker image available kong/kong:ca9c4ea8681062308b3a002c60e5f221e3d3f9a1
Artifacts available https://github.com/Kong/kong/actions/runs/10417441826

Please sign in to comment.