feat(IFC-1869): custom prefix length for from-pool IP allocation

Merged
SA
3mo ago
+2216-139

What

Adds an optional prefix-length override to the from-pool allocation flow for both IP address pools and IP prefix pools. When a user allocates from a pool (e.g. a device's Primary IP Address, or a subnet carved from a prefix pool), they can now request a specific prefix length instead of always getting the pool default. The pool's default is surfaced as the input placeholder.

๐Ÿ”— Try it live: /objects/InfraDevice in the preview environment โ€” open a device, edit its Primary IP Address, allocate from a pool, and set a custom prefix length.

Screenshots

Screenshot 2026-06-25 at 11 10 29 Screenshot 2026-06-25 at 11 10 38 image

Idempotency & the conflict error (FR-014)

Allocation stays idempotent โ€” the reserved resource never changes by re-allocating:

  • Re-selecting a pool that already holds a reservation for the object reuses it.
  • Supplying an explicit prefix length that conflicts with an existing reservation is now rejected with a clear inline error (its prefix length cannot be changed, only /<n> can be used) instead of being silently ignored. The guard (validate_reserved_prefix_length) is shared between CoreIPAddressPool and CoreIPPrefixPool. No GraphQL schema change.

Scope

  • Both IP address and IP prefix pools. Address pools take prefixlen (the new address's mask) and prefix pools take size (the carved-out subnet's prefix length) on their inline from_pool input โ€” both fields already exist in the schema, so no GraphQL input change was needed.
  • The IPAM create form (which allocates via the dedicated GetResource mutation rather than the generic from_pool path) threads the prefix length through as well.

Deferred / alternatives considered (FR-014)

  • Releasing the reservation on relationship re-point (too broad a behavior change, idempotency risk) and a read-only reserved-resource lookup endpoint (cleaner, larger โ€” good follow-up).

Testing

  • Backend: test_ipaddress_pool and test_prefix_pool โ€” a conflicting prefix length raises the anchored error; absent/matching stays idempotent.
  • Frontend: unit tests for the mutation builders (prefix length emitted only when set, mapped to prefixlen/size per pool kind), PoolPrefixLengthInput (incl. placeholder), updateFormFieldValue, and findErrorMessage.
  • E2E (pytest-playwright): custom-prefix-length allocation covered for both an IP address pool and an IP prefix pool โ€” asserting the pool default appears as the placeholder and the typed length is honoured. A shared select_pool helper de-duplicates the from-pool flow across the suite.
  • Manual: verified end-to-end in the live preview (conflict error, zero-effort reuse, fresh custom allocation for both pool kinds).

Spec

See dev/specs/ifc-1869-from-pool-prefix-mask/ โ€” reconciled to as-built.

Jira: IFC-1869

๐Ÿค– Generated with Claude Code