Skip to content

Add VRFRef to EVPNInstance and refactor L3VNI ownership#436

Open
felix-kaestner wants to merge 7 commits into
mainfrom
chore/l3vni
Open

Add VRFRef to EVPNInstance and refactor L3VNI ownership#436
felix-kaestner wants to merge 7 commits into
mainfrom
chore/l3vni

Conversation

@felix-kaestner

Copy link
Copy Markdown
Contributor

Move L3VNI configuration from the VRF resource to the EVPNInstance (Routed type). This aligns with how NX-OS models the relationship: the EVI owns the VNI-to-VRF binding, not the VRF itself.

  • Deprecate spec.vni on VRF in favor of the EVPNInstance VNI field
  • Add spec.vrfRef to EVPNInstance for Routed type (mirrors vlanRef for Bridged)
  • Refactor NX-OS provider: VRF uses Patch (preserves EVI-managed fields), EVI patches L3VNI/Encap separately
  • Restrict routeDistinguisher on EVPNInstance to Bridged type only
  • Support "Auto" value for route distinguisher (rd auto)
  • Reuse RouteDistinguisher/RouteTarget helpers across VRF and EVI providers

The L3 VNI is better suited on the EVPNInstance resource where it is
already present. Mark the VRF spec.vni field as deprecated and emit
an admission warning when it is set, guiding users to migrate to the
EVPNInstance VNI field instead.

Signed-off-by: Felix Kästner <felix.kaestner@sap.com>
Add a vrfRef field to EVPNInstance for Routed type (L3VNI/IP-VRF),
mirroring the existing vlanRef for Bridged type. The controller
resolves the VRF, validates same-device ownership, and passes it to
the provider.

Refactor the NX-OS provider to split VRF YANG writes between two
controllers:
- EnsureVRF patches leaf fields (name, description) and replaces
  the domain items (RD, route targets) via Update.
- EnsureEVPNInstance patches L3VNI/Encap on the VRF separately for
  Routed type instances.
- DeleteEVPNInstance clears L3VNI/Encap when the VRF still exists.

This avoids the two controllers overwriting each other's fields via
gNMI Replace on the same YANG subtree.

Signed-off-by: Felix Kästner <felix.kaestner@sap.com>
Add XValidation rule rejecting routeDistinguisher when type is Routed,
since the RD for an IP-VRF is configured on the VRF resource itself.
Update field documentation to clarify this constraint.

Signed-off-by: Felix Kästner <felix.kaestner@sap.com>
Replace inline RD and RT formatting logic with the existing
RouteDistinguisher() and RouteTarget() helpers from evi.go.

Signed-off-by: Felix Kästner <felix.kaestner@sap.com>
Signed-off-by: Felix Kästner <felix.kaestner@sap.com>
Change BDEVI.Rd from plain string to Option[string] so it is only
sent to the device when explicitly configured. Skip the RD call in
EnsureEVPNInstance when RouteDistinguisher is empty.

Signed-off-by: Felix Kästner <felix.kaestner@sap.com>
@felix-kaestner felix-kaestner requested a review from a team as a code owner July 8, 2026 15:56
Add RouteDistinguisherAuto constant and accept "Auto" as a special
value for the routeDistinguisher field on VRF and EVPNInstance. This
maps to "rd auto" on the device CLI (NX-OS: rd:unknown:0:0).

The extcommunity helper handles both empty and "Auto" as the auto-
derivation case, keeping RouteDistinguisher/RouteTarget as simple
wrappers.

Signed-off-by: Felix Kästner <felix.kaestner@sap.com>
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

Merging this branch changes the coverage (1 decrease, 2 increase)

Impacted Packages Coverage Δ 🤖
github.com/ironcore-dev/network-operator/api/core/v1alpha1 0.00% (ø)
github.com/ironcore-dev/network-operator/internal/controller/core 61.74% (-0.29%) 👎
github.com/ironcore-dev/network-operator/internal/provider 52.00% (ø)
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos 9.58% (+0.05%) 👍
github.com/ironcore-dev/network-operator/internal/webhook/core/v1alpha1 95.75% (+0.12%) 👍

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/ironcore-dev/network-operator/api/core/v1alpha1/evpninstance_types.go 0.00% (ø) 0 0 0
github.com/ironcore-dev/network-operator/api/core/v1alpha1/vrf_types.go 0.00% (ø) 0 0 0
github.com/ironcore-dev/network-operator/api/core/v1alpha1/zz_generated.deepcopy.go 0.00% (ø) 0 0 0
github.com/ironcore-dev/network-operator/internal/controller/core/evpninstance_controller.go 60.78% (-7.48%) 255 (+47) 155 (+13) 100 (+34) 👎
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/evi.go 42.55% (ø) 47 20 27
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/provider.go 0.05% (-0.00%) 1984 (+6) 1 1983 (+6) 👎
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/vrf.go 100.00% (ø) 8 (+2) 8 (+2) 0
github.com/ironcore-dev/network-operator/internal/provider/provider.go 52.00% (ø) 25 13 12
github.com/ironcore-dev/network-operator/internal/webhook/core/v1alpha1/vrf_webhook.go 97.62% (+0.40%) 42 (+6) 41 (+6) 1 👍

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files

  • github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/evi_test.go
  • github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/vrf_test.go
  • github.com/ironcore-dev/network-operator/internal/webhook/core/v1alpha1/vrf_webhook_test.go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant