Add support for L2VPN - #607
Open
flynn-nrg wants to merge 13 commits into
Open
Conversation
flynn-nrg
marked this pull request as ready for review
July 31, 2026 14:52
Collaborator
|
Hi @flynn-nrg, thanks for opening a PR. If a l2vpnclaim CR is created with the "identifier" field, is it equivalent to creating a l2vpn CR? |
Author
It follows the same pattern by the other claims like IpAddressClaim, so it will compute a restoration hash first and check if the matching object already exists. If not and there is a identifier it will be used directly to create a child L2VPN CR. |
Mirrors the existing IpAddress/IpAddressClaim envtest + gomock pattern: wires L2VPNReconciler/L2VPNClaimReconciler into the test manager with dedicated MockVpnAPI instances per reconciler, and covers reservation, update, restoration-hash mismatch, reserve failure, range allocation, restore-by-hash, explicit identifier, and lease-lock contention.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add L2VPN and L2VPNClaim support
Adds L2VPN (Layer 2 VPN) management to the NetBox Operator, following the same claim/resource pattern already used for IP addresses, prefixes, IP ranges and ASNs.
New CRDs
L2VPN— represents a single L2VPN in NetBox (name, type, identifier/VNI, tenant, comments, description, custom fields, preserveInNetbox).L2VPNClaim— claims an L2VPN identifier (VXLAN VNI) either as an exactidentifieror from anidentifierRangeStart/identifierRangeEndrange, and creates an ownedL2VPNCR.identifierand the range fields are mutually exclusive (CEL validation) and immutable once set.Controllers
L2VPNReconciler— reserves/updates the L2VPN in NetBox (ReserveOrUpdateL2VPN), finalizer-based cleanup (l2vpn.netbox.dev/finalizer), lease-locks the parent identifier range while the L2VPN is not yet Ready, reports conditions and events.L2VPNClaimReconciler— restores a previously assigned identifier by hash before falling back to the explicitidentifieror a new range-based allocation, syncs mutable fields down to the ownedL2VPN, lease-locks per range to avoid races between concurrent claims (l2vpnclaim.netbox.dev/finalizer).NetBox client
New methods on
NetboxCompositeClient:ReserveOrUpdateL2VPN,DeleteL2VPN,RestoreExistingL2VPNByHash,GetAvailableL2VPNIdentifierByClaim(scans existing L2VPNs, since NetBox has no dedicated "available identifiers" endpoint for L2VPN). NewL2VPN/L2VPNClaimmodels and regenerated mocks for theVpnL2vpns*API surface. ThenetboxOperatorRestorationHashcustom field is extended to covervpn.l2vpnin the kind data-load job.Tests & docs
pkg/netbox/api/l2vpn_test.go,l2vpn_claim_test.go) and for the controllers (internal/controller/l2vpn_controller_test.go,l2vpnclaim_controller_test.go), covering reservation, update, restoration-hash mismatch, reserve failure, range allocation, restore-by-hash, and lease-lock contention.tests/e2e/l2vpn: explicit/range apply-update, range restore, range-exhausted, invalid tenant/custom-field, and owner-reference cases.config/samples/.L2VPN/L2VPNClaimmodel and usage.Behaviour notes
preserveInNetbox: truekeeps the L2VPN in NetBox after CR deletion, enabling later reclaim.name,type,identifierandtenantimmutability enforced via CEL validation rules on bothL2VPNandL2VPNClaim.This was done with the help of Claude. I haven't seen anything in the docs about it so I assume it's fine.