]> git.puffer.fish Git - matthieu/pve-network.git/commit
partial fix #5496: subnet: ipam: add update_subnet hook
authorStefan Hanreich <s.hanreich@proxmox.com>
Mon, 10 Mar 2025 08:51:03 +0000 (09:51 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 7 Apr 2025 15:43:56 +0000 (17:43 +0200)
commit1b01ad6529516790cc19b22c2c389e1c41530738
tree61858901e7ade9bb526f53a4265b200b72df5da3
parenta52a40c78b82e0646c60a28fc9919336a2cb1290
partial fix #5496: subnet: ipam: add update_subnet hook

Because of how the Netbox IPAM plugin works (utilizing IP ranges to
represent DHCP ranges), we need a hook in the IPAM plugin that runs on
updates to the subnet because DHCP ranges can be edited. The update
hook in Netbox checks which DHCP ranges got added and which got
deleted and then performs the respective changes in the Netbox IPAM.
This operates under the assumption that DHCP ranges do not overlap
(which is not supported by Netbox anyway).

Only Netbox needs to do work on update, so we can leave this as noop
in phpIPAM and the PVE IPAM, because they have no notion of IP ranges
or similar entities. phpIPAM doesn't support DHCP ranges at all and
PVE IPAM simply uses DHCP ranges as a constraint when allocating an
IP.

I decided on this approach over just creating IP ranges on demand when
assigning IPs, because this keeps Netbox clean and in sync with the
PVE state. It doesn't leave remnants of IP ranges in the Netbox
database, which can lead to errors when trying to create IP ranges
that overlap with IP ranges that already existed in an SDN subnet.

This method tries to check for any possible errors before editing the
entities. There is still a small window where external changes can
occur that lead to errors. We are touching multiple entities here, so
in case of errors users have to fix their Netbox instance manually.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
Tested-by: Hannes Duerr <h.duerr@proxmox.com>
Link: https://lore.proxmox.com/20250310085103.30549-8-s.hanreich@proxmox.com
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/Network/SDN/Ipams/NetboxPlugin.pm
src/PVE/Network/SDN/Ipams/PVEPlugin.pm
src/PVE/Network/SDN/Ipams/PhpIpamPlugin.pm
src/PVE/Network/SDN/Ipams/Plugin.pm
src/PVE/Network/SDN/SubnetPlugin.pm
src/PVE/Network/SDN/Subnets.pm