feat(diagnostics): sample what the resolver answers, not just its socket

Run 32118850138 lost the :53 listener, so the sampler counts listeners.
Run 32538854067 lost DNS with the listener still bound: sockets-udp.txt
showed dnsmasq holding 0.0.0.0:53 while every forwarded query timed out,
and the sampler reported that hour as healthy.

Each tick now also records what a glibc caller gets back — for the zone
this resolver owns, derived from its own address= line, and for one name
it must forward — with the latency that caller paid. The rescue collector
probes the in-zone name too: probing external names alone cannot separate
"forwarding is gone" from "dnsmasq is gone".

The sampler now also runs on the swarm lab DNS nodes; it only ever ran in
the compose path, which is why the Magento artifact carried no sampler log
at all. Its location comes from group_vars FILE_DNS53_SAMPLER_LOG and is
required at every call site, so a run cannot quietly collect nothing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
kevinveenbirkenbachandClaude Opus 5 committed 2026-08-22 17:55:05 +02:00
1 parent 7e5154033e
commit d14354e892
10 files changed
+162 -11

No files matched your search

@@ -57,5 +57,62 @@ class SamplerTickTests(unittest.TestCase):
self.assertRegex(line, TIMESTAMP + r" none$")
class AnswerProbeTests(unittest.TestCase):
def _answer(self, name: str) -> str:
proc = subprocess.run(
[
"sh",
"-c",
'DNS53_SAMPLER_LIB=1 . "$1" && answer_once "$2"',
"sh",
str(SAMPLER),
name,
],
capture_output=True,
text=True,
check=True,
)
return proc.stdout
def test_a_resolvable_name_is_reported_ok_with_its_latency(self):
self.assertRegex(self._answer("localhost"), r"^ localhost=ok/\d+ms$")
def test_an_unresolvable_name_is_reported_fail_not_skipped(self):
self.assertRegex(
self._answer("rescue-probe.invalid"),
r"^ rescue-probe\.invalid=fail/\d+ms$",
)
class ZoneProbeNameTests(unittest.TestCase):
def _zone(self, conf: str) -> str:
with tempfile.NamedTemporaryFile("w", suffix=".conf") as handle:
handle.write(conf)
handle.flush()
proc = subprocess.run(
[
"sh",
"-c",
'DNS53_SAMPLER_LIB=1 . "$1" && zone_probe_name "$2"',
"sh",
str(SAMPLER),
handle.name,
],
capture_output=True,
text=True,
check=True,
)
return proc.stdout
def test_the_owned_zone_becomes_a_probe_name(self):
self.assertEqual(
self._zone("no-resolv\naddress=/infinito.example/192.168.244.10\n"),
"rescue-probe.infinito.example",
)
def test_a_config_without_a_zone_yields_nothing(self):
self.assertEqual(self._zone("no-resolv\nserver=192.0.2.1\n"), "")
if __name__ == "__main__":
unittest.main()