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

dnsdist: Use getAddressInfo() instead python daemonized subprocess #15032

Merged
merged 3 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 1 addition & 3 deletions Dockerfile-dnsdist
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,9 @@ FROM debian:12-slim
RUN apt-get update && apt-get -y dist-upgrade && apt-get clean

# - python3 and jinja2 (for startup script)
# - python3-atomicwrites (for backend management)
# - tini (for signal management)
# - ca-certificates (for verifying downstream DoH/DoT certificates)
RUN apt-get install -y python3 python3-jinja2 python3-atomicwrites tini libcap2-bin ca-certificates && apt-get clean
RUN apt-get install -y python3 python3-jinja2 tini libcap2-bin ca-certificates && apt-get clean

# Output from builder
COPY --from=builder /build /
Expand Down Expand Up @@ -126,6 +125,5 @@ EXPOSE 8083/tcp
WORKDIR /etc/dnsdist

COPY dockerdata/dnsdist-resolver.lua /etc/dnsdist/
COPY dockerdata/dnsdist-resolver.py /usr/local/bin/dnsdist-resolver

ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/dnsdist-startup"]
25 changes: 10 additions & 15 deletions dockerdata/dnsdist-resolver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@ _M.verbose = false
local ourservers = {}
local ourcount = {}

local resolverpipe = io.popen('/usr/local/bin/dnsdist-resolver', 'w')
-- Global variable for store results for getAddressInfo() function
local resout = {}

local function resolveCB(hostname, ips)
resout[hostname] = {}
for _, ip in ipairs(ips) do
table.insert(resout[hostname], ip:toString())
end
end

local function tablecopy(t)
local t2 = {}
Expand Down Expand Up @@ -71,22 +79,9 @@ local function setServer(name, ip)
end

function _M.maintenance()
-- TODO: only do this if the list has changed
-- TODO: check return values
for k in pairs(_M.servers) do
resolverpipe:write(k .. ' ')
getAddressInfo(k, resolveCB)
end
resolverpipe:write('\n')
resolverpipe:flush()

-- TODO: maybe this failure should be quiet for the first X seconds?
local ret, resout = pcall(loadfile, '/tmp/dnsdist-resolver.out')
if not ret then
error(resout)
end

-- on purpose no pcall, an error here is a bug
resout = resout()

local activeservers = {}
-- check for servers removed by controller
Expand Down
43 changes: 0 additions & 43 deletions dockerdata/dnsdist-resolver.py

This file was deleted.

Loading