Skip to content

Add AsnClaim and Asn - #606

Open
jstudler wants to merge 1 commit into
mainfrom
feature/add-asn
Open

Add AsnClaim and Asn#606
jstudler wants to merge 1 commit into
mainfrom
feature/add-asn

Conversation

@jstudler

@jstudler jstudler commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Add ASN and AsnClaim support

Adds ASN (Autonomous System Number) management to the NetBox Operator, following the same claim/resource pattern already used for IP addresses, prefixes and IP ranges.

New CRDs

  • Asn — represents a single ASN in NetBox.
  • AsnClaim — claims an available ASN from a NetBox ASN Range via parentAsnRange (matched by range name) and creates an owned Asn CR. Status exposes the assigned asn and asnName.

Controllers

  • AsnReconciler — reserves/updates the ASN in NetBox, finalizer-based cleanup (asn.netbox.dev/finalizer), lease-locks the parent ASN range while the ASN is not yet Ready, tracks managed custom fields via annotation, reports conditions and events.
  • AsnClaimReconciler — allocates an ASN from the parent range, restores a previously assigned ASN by hash before falling back to a new allocation, syncs mutable fields down to the owned Asn, lease-locks per range to avoid races between concurrent claims.

NetBox client

New methods on NetboxCompositeClient: ReserveOrUpdateAsn, DeleteAsn, RestoreExistingAsnByHash, GetAvailableAsnByClaim, plus internal RIR resolution and ASN-range-by-name lookup. New ASN / ASNClaim models and regenerated mocks for the IpamAsns* / IpamAsnRanges* API surface.

Tests & docs

  • Unit tests for controllers, helpers and the NetBox client.
  • Chainsaw e2e tests under tests/e2e/asn: apply/update, restore, range-exhausted and owner-reference cases; local test data (RIR + ASN ranges) seeded in the kind data-load job.
  • README section "ASN Management" documenting the Asn/AsnClaim model, parentAsnRange semantics and restoration.

Behaviour notes

  • Restoration hash makes ASN assignment sticky across CR re-creation; a hash mismatch on a not-yet-reserved Asn deletes the CR.
  • preserveInNetbox: true keeps the ASN in NetBox after CR deletion, enabling later reclaim.
  • asn and tenant immutability is enforced by CEL validation rules.

Open Questions

  • Use Name of Parent ASN Range (e.g. "E2E Test ASN Range") or the actual range (e.g. "64512-64612")?
  • Inherit RIR from parent ASN Range or not?

@jstudler jstudler self-assigned this Jul 31, 2026
@jstudler
jstudler force-pushed the feature/add-asn branch 2 times, most recently from 4bce36d to 4c476e7 Compare July 31, 2026 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant