unbound variable my_dns_latency
Closed this issue · 2 comments
aspyk commented
I just tried to run the docker compose and I saw this in the log after a short while:
netprobe-probe | Error performing DNS resolution on ('My_DNS_Server', '8.8.8.8')Error performing DNS resolution on ('Google_DNS', '8.8.8.8')
netprobe-probe | The resolution lifetime expired after 5.106 seconds: Server Do53:8.8.8.8@53 answered The DNS operation timed out.
netprobe-probe | Error performing DNS resolution on ('CloudFlare_DNS', '1.1.1.1')
netprobe-probe | The resolution lifetime expired after 5.103 seconds: Server Do53:8.8.8.8@53 answered The DNS operation timed out.
netprobe-probe |
netprobe-probe | The resolution lifetime expired after 5.106 seconds: Server Do53:1.1.1.1@53 answered The DNS operation timed out.
netprobe-probe | Error performing DNS resolution on ('Quad9_DNS', '9.9.9.9')
netprobe-probe | The resolution lifetime expired after 5.106 seconds: Server Do53:9.9.9.9@53 answered The DNS operation timed out.
netprobe-presentation | Traceback (most recent call last):
netprobe-presentation | File "/usr/lib/python3.12/wsgiref/handlers.py", line 137, in run
netprobe-presentation | self.result = application(self.environ, self.start_response)
netprobe-presentation | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
netprobe-presentation | File "/usr/local/lib/python3.12/dist-packages/prometheus_client/exposition.py", line 128, in prometheus_app
netprobe-presentation | status, headers, output = _bake_output(registry, accept_header, accept_encoding_header, params, disable_compression)
netprobe-presentation | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
netprobe-presentation | File "/usr/local/lib/python3.12/dist-packages/prometheus_client/exposition.py", line 104, in _bake_output
netprobe-presentation | output = encoder(registry)
netprobe-presentation | ^^^^^^^^^^^^^^^^^
netprobe-presentation | File "/usr/local/lib/python3.12/dist-packages/prometheus_client/openmetrics/exposition.py", line 21, in generate_latest
netprobe-presentation | for metric in registry.collect():
netprobe-presentation | File "/usr/local/lib/python3.12/dist-packages/prometheus_client/registry.py", line 97, in collect
netprobe-presentation | yield from collector.collect()
netprobe-presentation | File "/netprobe_lite/presentation.py", line 106, in collect
netprobe-presentation | if my_dns_latency / threshold_dns_latency >= 1:
netprobe-presentation | ^^^^^^^^^^^^^^
netprobe-presentation | UnboundLocalError: cannot access local variable 'my_dns_latency' where it is not associated with a value
It seems no DNS are reachable from the docker, and so the variable my_dns_latency
is not properly set and raises an unbound error. When I change the default local DNS IP, it works as expected (except that the others DNS are stil not reachable).
plaintextpackets commented
Testing the fix here: https://github.com/plaintextpackets/netprobe_lite/tree/issue_27
When DNS times out it will report the value as 5 seconds (which is the timeout on the DNS resolver)
Can't set it to 0 as that would skew the performance score positively, and make no sense. This way at least you can tell there's an issue because of DNS, and the other tests still work.
plaintextpackets commented