Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions metalnetlet/controllers/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ func ipsIPFamilies(ips []net.IP) []corev1.IPFamily {
return utilslices.Map(ips, net.IP.Family)
}

func metalnetNetworkInterfaceStateToNetworkInterfaceStatus(mStatus metalnetv1alpha1.NetworkInterfaceState) v1alpha1.NetworkInterfaceState {
switch mStatus {
case metalnetv1alpha1.NetworkInterfaceStatePending:
return v1alpha1.NetworkInterfaceStatePending
case metalnetv1alpha1.NetworkInterfaceStateReady:
return v1alpha1.NetworkInterfaceStateReady
case metalnetv1alpha1.NetworkInterfaceStateError:
return v1alpha1.NetworkInterfaceStateError
default:
return v1alpha1.NetworkInterfaceStatePending
}
}

func metalnetIPToIP(ip metalnetv1alpha1.IP) net.IP {
return net.IP{Addr: ip.Addr}
}
Expand Down
1 change: 1 addition & 0 deletions metalnetlet/controllers/networkinterface_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ func (r *NetworkInterfaceReconciler) updateStatus(
metalnetNic *metalnetv1alpha1.NetworkInterface,
) error {
base := nic.DeepCopy()
nic.Status.State = metalnetNetworkInterfaceStateToNetworkInterfaceStatus(metalnetNic.Status.State)
if pciAddr := metalnetNic.Status.PCIAddress; pciAddr != nil {
nic.Status.PCIAddress = &v1alpha1.PCIAddress{
Domain: pciAddr.Domain,
Expand Down
22 changes: 22 additions & 0 deletions metalnetlet/controllers/networkinterface_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,28 @@ var _ = Describe("NetworkInterfaceController", func() {
NodeName: &metalnetNode.Name,
}))

By("updating the metalnet network interface's status")
Eventually(UpdateStatus(metalnetNic, func() {
metalnetNic.Status.State = metalnetv1alpha1.NetworkInterfaceStateReady
metalnetNic.Status.PCIAddress = &metalnetv1alpha1.PCIAddress{
Domain: "06",
Bus: "0000",
Slot: "3",
Function: "00",
}
})).Should(Succeed())

By("waiting for the network interface to reflect the status values")
Eventually(Object(nic)).Should(HaveField("Status", v1alpha1.NetworkInterfaceStatus{
State: v1alpha1.NetworkInterfaceStateReady,
PCIAddress: &v1alpha1.PCIAddress{
Domain: "06",
Bus: "0000",
Slot: "3",
Function: "00",
},
}))

By("deleting the network interface")
Expect(k8sClient.Delete(ctx, nic)).To(Succeed())

Expand Down