When Kea, ISC DHCP and the ARP fallback all failed, get_dhcp_leases() returned [], which a caller cannot tell from a server with no leases. netOrk is changing its poll so that an empty answer clears the stored leases (NetOrk/netork#1189); with the old behaviour an API outage would wipe them. The driver now raises when nothing could be read.
Changes
get_dhcp_leases() records which sources answered and why the others failed; raises RuntimeError("No DHCP lease source answered -- Kea: …; ISC DHCP: …; ARP table: …") instead of return [].
Rule (in the docstring): Kea/ISC leases first; else the ARP rows (state: "arp"); [] only when a lease source answered empty; both lease sources failed and ARP failed or empty → raise (ARP rows are no lease data).
Driver suite: 441 passed (the two "nothing answered" cases red before).
netOrk: a real OPNsenseDriver with every request failing gives dhcp_leases: None in the poll, so stored leases are kept; 321 related netOrk tests passed.
## Summary
When Kea, ISC DHCP and the ARP fallback all failed, `get_dhcp_leases()` returned `[]`, which a caller cannot tell from a server with no leases. netOrk is changing its poll so that an empty answer clears the stored leases (NetOrk/netork#1189); with the old behaviour an API outage would wipe them. The driver now raises when nothing could be read.
## Changes
- `get_dhcp_leases()` records which sources answered and why the others failed; raises `RuntimeError("No DHCP lease source answered -- Kea: …; ISC DHCP: …; ARP table: …")` instead of `return []`.
- Rule (in the docstring): Kea/ISC leases first; else the ARP rows (`state: "arp"`); `[]` only when a lease source answered empty; both lease sources failed and ARP failed or empty → raise (ARP rows are no lease data).
- New `tests/unit/test_dhcp_leases.py` (9 cases).
## Related Issue
Closes #27
## Testing
- Driver suite: 441 passed (the two "nothing answered" cases red before).
- netOrk: a real `OPNsenseDriver` with every request failing gives `dhcp_leases: None` in the poll, so stored leases are kept; 321 related netOrk tests passed.
When Kea, ISC DHCP and the ARP fallback all failed, get_dhcp_leases()
returned [], which a caller cannot tell from a server with no leases. It now
raises a RuntimeError naming each failure, and returns [] only when a source
answered with nothing. An empty ARP table after both lease sources failed
counts as unread too, since ARP rows are no lease data.
Closes#27
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
When Kea, ISC DHCP and the ARP fallback all failed,
get_dhcp_leases()returned[], which a caller cannot tell from a server with no leases. netOrk is changing its poll so that an empty answer clears the stored leases (NetOrk/netork#1189); with the old behaviour an API outage would wipe them. The driver now raises when nothing could be read.Changes
get_dhcp_leases()records which sources answered and why the others failed; raisesRuntimeError("No DHCP lease source answered -- Kea: …; ISC DHCP: …; ARP table: …")instead ofreturn [].state: "arp");[]only when a lease source answered empty; both lease sources failed and ARP failed or empty → raise (ARP rows are no lease data).tests/unit/test_dhcp_leases.py(9 cases).Related Issue
Closes #27
Testing
OPNsenseDriverwith every request failing givesdhcp_leases: Nonein the poll, so stored leases are kept; 321 related netOrk tests passed.