DNS: a failed service detection reads as "no DNS service" — get_dns_entries() returns [] and netOrk drops the firewall's records #39

Closed
opened 2026-11-01 21:44:46 +00:00 by christianmanivong · 0 comments
Owner

What happens

_detect_active_dns (napalm_opnsense/opnsense.py 2809-2819) catches every exception from /api/core/service/search, logs a warning (line 2818) and returns None:

logger.warning("DNS service detection failed: %s", exc)

Its callers cannot tell a failed request from "neither Unbound nor Dnsmasq runs":

  • get_dns_entries() (line 2842) returns []. netOrk treats an empty answer as "read, none" and removes the device's DNS records (netork/jobs/tasks/poll/_dns_entries.py: "an empty answer removes them"; a raised error would have kept them, #1458). One transient API error during a poll therefore wipes the firewall's records in netOrk until the next poll.
  • sync_dns_zone (line 2981-2983) raises "No active DNS service (Unbound or Dnsmasq) detected", which sends the operator looking at the DNS service instead of the API error.

Related: #14 (the host-override readers swallow errors and return [], which makes sync_dns_zone duplicate overrides). That fix covers the readers; this one is the detection in front of them, and the same [] reaches get_dns_entries.

Expected

_detect_active_dns lets the request error propagate (or raises its own ConnectionException with the cause); None only when the search succeeded and neither service runs. Test-first: a failing service/search makes get_dns_entries() raise and sync_dns_zone report the API error.

Priority: P3 — DNS records disappear from netOrk after any transient API error, and the sync error names the wrong cause.

Found during the bug sweep of 2026-11-01.

## What happens `_detect_active_dns` (`napalm_opnsense/opnsense.py` 2809-2819) catches every exception from `/api/core/service/search`, logs a warning (line 2818) and returns `None`: ```python logger.warning("DNS service detection failed: %s", exc) ``` Its callers cannot tell a failed request from "neither Unbound nor Dnsmasq runs": - `get_dns_entries()` (line 2842) returns `[]`. netOrk treats an empty answer as "read, none" and removes the device's DNS records (`netork/jobs/tasks/poll/_dns_entries.py`: "an empty answer removes them"; a raised error would have kept them, #1458). One transient API error during a poll therefore wipes the firewall's records in netOrk until the next poll. - `sync_dns_zone` (line 2981-2983) raises `"No active DNS service (Unbound or Dnsmasq) detected"`, which sends the operator looking at the DNS service instead of the API error. Related: #14 (the host-override readers swallow errors and return `[]`, which makes `sync_dns_zone` duplicate overrides). That fix covers the readers; this one is the detection in front of them, and the same `[]` reaches `get_dns_entries`. ## Expected `_detect_active_dns` lets the request error propagate (or raises its own `ConnectionException` with the cause); `None` only when the search succeeded and neither service runs. Test-first: a failing `service/search` makes `get_dns_entries()` raise and `sync_dns_zone` report the API error. Priority: P3 — DNS records disappear from netOrk after any transient API error, and the sync error names the wrong cause. Found during the bug sweep of 2026-11-01.
christianmanivong added the
prio
P3
bug
labels 2026-11-01 21:44:46 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: NAPALM/napalm-opnsense#39