fix: leave an unchanged Kea reservation and Kea alone #28

Merged
christianmanivong merged 1 commits from fix/kea-skip-unchanged-reservation into master 2026-10-20 23:36:55 +00:00
Owner

Summary

create_dhcp_reservation rewrote an existing reservation and called /api/kea/service/reconfigure even when the reservation already held exactly what was asked (e.g. a retried provisioning job). On OPNsense that reconfigure stops and starts Kea, which once left a firewall without DHCP (NetOrk/netork#1142/#1143). An unchanged reservation is now left alone.

Changes

  • create_dhcp_reservation keeps the matched searchReservation row and returns early when it already matches.
  • New _kea_reservation_unchanged(row, wanted, subnet_cidr): subnet as UUID or CIDR, MAC normalised (napalm_device_types.dhcp.normalize_mac), IP, hostname and description exact; a missing field counts as different (writes once too often rather than skipping a needed write).
  • delete_dhcp_reservation_and_lease already reconfigures only when it deleted something; unchanged.
  • Return contract unchanged; no version bump (plain fix, as in earlier fix commits).

Why no reload instead of the restart: in opnsense/core 26.7.7 (and master) the Kea ServiceController keeps reconfigureForceRestart() = true and actions_kea.conf has no [reload] action, so the REST API offers no soft reload. Options are collected in NetOrk/netork#1324.

Related Issue

Refs NetOrk/netork#1187 (closed there by the pin bump)

Testing

  • New: test_unchanged_reservation_is_neither_written_nor_reconfigured (subnet as CIDR and as UUID, MAC in another notation) — red before, green after.
  • New: test_reservation_differing_in_one_field_is_written_and_reconfigured (hw_address, hostname, description, subnet).
  • Driver suite: 438 passed. netOrk tests touching provisioning/DHCP with this driver: 138 passed.
## Summary `create_dhcp_reservation` rewrote an existing reservation and called `/api/kea/service/reconfigure` even when the reservation already held exactly what was asked (e.g. a retried provisioning job). On OPNsense that reconfigure stops and starts Kea, which once left a firewall without DHCP (NetOrk/netork#1142/#1143). An unchanged reservation is now left alone. ## Changes - `create_dhcp_reservation` keeps the matched `searchReservation` row and returns early when it already matches. - New `_kea_reservation_unchanged(row, wanted, subnet_cidr)`: subnet as UUID or CIDR, MAC normalised (`napalm_device_types.dhcp.normalize_mac`), IP, hostname and description exact; a missing field counts as different (writes once too often rather than skipping a needed write). - `delete_dhcp_reservation_and_lease` already reconfigures only when it deleted something; unchanged. - Return contract unchanged; no version bump (plain fix, as in earlier fix commits). Why no reload instead of the restart: in opnsense/core 26.7.7 (and master) the Kea `ServiceController` keeps `reconfigureForceRestart()` = true and `actions_kea.conf` has no `[reload]` action, so the REST API offers no soft reload. Options are collected in NetOrk/netork#1324. ## Related Issue Refs NetOrk/netork#1187 (closed there by the pin bump) ## Testing - New: `test_unchanged_reservation_is_neither_written_nor_reconfigured` (subnet as CIDR and as UUID, MAC in another notation) — red before, green after. - New: `test_reservation_differing_in_one_field_is_written_and_reconfigured` (hw_address, hostname, description, subnet). - Driver suite: 438 passed. netOrk tests touching provisioning/DHCP with this driver: 138 passed.
christianmanivong added 1 commit 2026-10-20 23:02:26 +00:00
fix: leave an unchanged Kea reservation and Kea alone
CI / test (3.10) (push) Successful in 35s
CI / test (3.11) (push) Successful in 32s
CI / test (3.12) (push) Successful in 34s
CI / test (3.10) (pull_request) Successful in 31s
CI / test (3.11) (pull_request) Successful in 30s
CI / test (3.12) (pull_request) Successful in 34s
59796b3fa1
create_dhcp_reservation rewrote an existing reservation and called
service/reconfigure even when it already held exactly what was asked, e.g.
on a retried provisioning job. reconfigure stops and starts Kea (the Kea
service controller keeps reconfigureForceRestart() = true and configd has no
reload action), which once left a firewall without DHCP. A reservation whose
subnet, MAC (normalised), IP, hostname and description already match is now
left alone.

Refs NetOrk/netork#1187
christianmanivong merged commit 68dbd5891c into master 2026-10-20 23:36:55 +00:00
christianmanivong deleted branch fix/kea-skip-unchanged-reservation 2026-10-20 23:36:55 +00:00
Sign in to join this conversation.