Skip to content

Add dhcp relay to l3 interfaces#256

Open
nikatza wants to merge 6 commits intomainfrom
add-dhcp-relay-to-l3-interfaces
Open

Add dhcp relay to l3 interfaces#256
nikatza wants to merge 6 commits intomainfrom
add-dhcp-relay-to-l3-interfaces

Conversation

@nikatza
Copy link
Contributor

@nikatza nikatza commented Mar 24, 2026

No description provided.

@hardikdr hardikdr added the area/switch-automation Automation processes for network switch management and operations. label Mar 25, 2026
@hardikdr hardikdr added this to Roadmap Mar 25, 2026
@nikatza nikatza force-pushed the add-dhcp-relay-to-l3-interfaces branch 3 times, most recently from 02eab6f to f30d465 Compare March 25, 2026 11:10
@nikatza nikatza marked this pull request as ready for review March 25, 2026 11:11
@nikatza nikatza requested a review from a team as a code owner March 25, 2026 11:11
@nikatza nikatza force-pushed the add-dhcp-relay-to-l3-interfaces branch from f30d465 to 579d696 Compare March 25, 2026 12:23
Add core types to configure DHCP relay on L3 interfaces.

The DHCPRelay resource is device-scoped (one per device) and references
a list of Layer 3 interfaces where DHCP relay should be enabled, along
with the DHCP server addresses.

Supported interface types are Physical, Aggregate, and RoutedVLAN (Layer
3 SVIs). The controller will validate that all referenced interfaces
belong to the same device and are configured with IPv4 addressing.

The optional VrfRef field allows specifying which VRF context should be
used when forwarding DHCP messages to the servers.
@nikatza nikatza force-pushed the add-dhcp-relay-to-l3-interfaces branch 4 times, most recently from 8187976 to 07e796b Compare March 25, 2026 12:59
// InterfaceRefs is a list of interfaces
// +optional
// +listType=atomic
InterfaceRefs []LocalObjectReference `json:"interfaceRefs,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
InterfaceRefs []LocalObjectReference `json:"interfaceRefs,omitempty"`
// +kubebuilder:validation:MinItems=1
InterfaceRefs []LocalObjectReference `json:"interfaceRefs,omitempty"`

should we require at least 1?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to leave the user the option to have the resource disabled with no referenced interfaces. But no strong opinion, i will add this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point. I think we have the same situation in other resources, such as the NTP.

nikatza added 5 commits March 25, 2026 16:46
The controller validates that the referenced Device exists and is not
paused, that all InterfaceRefs belong to the same device and are Layer 3
interfaces (Physical, Aggregate, or RoutedVLAN types) with IPv4
configuration, and that the optional VrfRef belongs to the same device.

It enforces that only one DHCPRelay resource exists per device.

The controller retrieves the list of interfaces that have DHCP relay
configured on the device and updates the ConfiguredInterfaceRefs status
field.

The controller watches for Device Paused field changes, Interface Ready
condition changes, VRF Ready condition changes, and ProviderConfig
updates to trigger re-reconciliation when dependencies change.

The controller considers only the Configuration condition of the
referenced resources as DHCPRelay is a configuration resource only.
Enable or disable the DHCP feature based on AdminState. When enabled,
configure DHCP relay on each referenced interface with the specified
server addresses.

The provider uses the VRF context from VrfRef (or the NXOS default
"!unspecified" if no VRF is specified) when configuring server
addresses.

The implementation uses the Update operation to ensure stale DHCP relay
entries are removed when the configuration changes. This also affects
entries referencing interfaces not managed by the operator.

The entire tree is removed on deletion, affecting non-managed interfaces.,
It leaves the DHCP feature in its current state.

GetDHCPRelayStatus queries the device for all interfaces with DHCP relay
configured and returns their names.
SA1019: LoadCertificate is deprecated but we still it on NXOS
@nikatza nikatza force-pushed the add-dhcp-relay-to-l3-interfaces branch from 07e796b to eb1d240 Compare March 25, 2026 16:19
@github-actions
Copy link

Merging this branch will decrease overall coverage

Impacted Packages Coverage Δ 🤖
github.com/ironcore-dev/network-operator/api/core/v1alpha1 0.00% (ø)
github.com/ironcore-dev/network-operator/cmd 0.00% (ø)
github.com/ironcore-dev/network-operator/internal/controller/core 62.73% (-0.15%) 👎
github.com/ironcore-dev/network-operator/internal/provider 52.00% (ø)
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos 10.49% (-0.18%) 👎

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/ironcore-dev/network-operator/api/core/v1alpha1/dhcprelay_types.go 0.00% (ø) 0 0 0
github.com/ironcore-dev/network-operator/api/core/v1alpha1/groupversion_info.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/cmd/main.go 0.00% (ø) 0 0 0
github.com/ironcore-dev/network-operator/internal/controller/core/dhcprelay_controller.go 62.22% (+62.22%) 270 (+270) 168 (+168) 102 (+102) 🌟
github.com/ironcore-dev/network-operator/internal/controller/core/lldp_controller.go 68.00% (-0.14%) 200 (-4) 136 (-3) 64 (-1) 👎
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/cert.go 3.33% (ø) 30 1 29
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/dhcprelay.go 0.00% (ø) 3 (+3) 0 3 (+3)
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/provider.go 0.06% (-0.00%) 1577 (+35) 1 1576 (+35) 👎
github.com/ironcore-dev/network-operator/internal/provider/provider.go 52.00% (ø) 25 13 12

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/controller/core/dhcprelay_controller_test.go
  • github.com/ironcore-dev/network-operator/internal/controller/core/suite_test.go

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

Labels

area/switch-automation Automation processes for network switch management and operations.

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants