Skip to content

Commit

Permalink
Propagate NetworkInterface IPs in Machine status
Browse files Browse the repository at this point in the history
Add the `NetworkInterface` IPs in `Machine` status as soon as they are
available and propageted by the machine runtime.
  • Loading branch information
afritzler committed Dec 4, 2024
1 parent ccbc073 commit 655094b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -382,11 +382,17 @@ func (r *MachineReconciler) convertIRINetworkInterfaceStatus(status *iri.Network
return computev1alpha1.NetworkInterfaceStatus{}, err
}

ips := make([]commonv1alpha1.IP, len(status.Ips))
for i, ip := range status.Ips {
ips[i] = commonv1alpha1.MustParseIP(ip)
}

return computev1alpha1.NetworkInterfaceStatus{
Name: status.Name,
Handle: status.Handle,
State: state,
NetworkInterfaceRef: corev1.LocalObjectReference{Name: nicName},
IPs: ips,
}, nil
}

Expand All @@ -398,6 +404,7 @@ func (r *MachineReconciler) addNetworkInterfaceStatusValues(now metav1.Time, exi
existing.NetworkInterfaceRef = newValues.NetworkInterfaceRef
existing.State = newValues.State
existing.Handle = newValues.Handle
existing.IPs = newValues.IPs
}

func (r *MachineReconciler) getNetworkInterfaceStatusesForMachine(
Expand Down
2 changes: 2 additions & 0 deletions poollet/machinepoollet/controllers/machine_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ var _ = Describe("MachineController", func() {
"Handle": Equal("primary-handle"),
"State": Equal(computev1alpha1.NetworkInterfaceStateAttached),
"NetworkInterfaceRef": Equal(corev1.LocalObjectReference{Name: computev1alpha1.MachineEphemeralNetworkInterfaceName(machine.Name, "primary")}),
"IPs": Equal([]commonv1alpha1.IP{commonv1alpha1.MustParseIP("10.0.0.11")}),
}))))

By("removing the network interface from the machine")
Expand Down Expand Up @@ -321,6 +322,7 @@ var _ = Describe("MachineController", func() {
"Handle": Equal("primary-handle"),
"State": Equal(computev1alpha1.NetworkInterfaceStateAttached),
"NetworkInterfaceRef": Equal(corev1.LocalObjectReference{Name: nic.Name}),
"IPs": Equal([]commonv1alpha1.IP{commonv1alpha1.MustParseIP("10.0.0.1")}),
}))))

By("removing the network interface from the machine")
Expand Down

0 comments on commit 655094b

Please sign in to comment.