diff --git a/pkg/api/machine.go b/pkg/api/machine.go index 3af71157..0d5e9220 100644 --- a/pkg/api/machine.go +++ b/pkg/api/machine.go @@ -4,7 +4,6 @@ package api import ( - "net" "time" ) @@ -97,7 +96,7 @@ type NetworkInterfaceStatus struct { Name string `json:"name"` Handle string `json:"handle"` State NetworkInterfaceState `json:"state"` - IPs []net.IP `json:"ips"` + IPs []string `json:"ips"` } type NetworkInterfaceState string diff --git a/pkg/controllers/machine_controller_nics.go b/pkg/controllers/machine_controller_nics.go index 34537977..405b6d37 100644 --- a/pkg/controllers/machine_controller_nics.go +++ b/pkg/controllers/machine_controller_nics.go @@ -172,6 +172,7 @@ func (r *MachineReconciler) attachDetachNetworkInterfaces( Name: nicName, Handle: mountedNic.networkInterface.Handle, State: api.NetworkInterfaceStateAttached, + IPs: desiredNic.Ips, }) } } diff --git a/pkg/plugins/networkinterface/apinet/apinet.go b/pkg/plugins/networkinterface/apinet/apinet.go index 3caa92bc..f072809d 100644 --- a/pkg/plugins/networkinterface/apinet/apinet.go +++ b/pkg/plugins/networkinterface/apinet/apinet.go @@ -9,7 +9,6 @@ import ( "encoding/json" "errors" "fmt" - "net" "os" "path/filepath" "strconv" @@ -147,24 +146,8 @@ func (p *Plugin) Apply(ctx context.Context, spec *api.NetworkInterfaceSpec, mach return nil, fmt.Errorf("error applying apinet network interface: %w", err) } - hostDev, err := getHostDevice(apinetNic) - if err != nil { - return nil, fmt.Errorf("error getting host device: %w", err) - } - if hostDev != nil { - log.V(1).Info("Host device is ready", "HostDevice", hostDev) - return &providernetworkinterface.NetworkInterface{ - Handle: provider.GetNetworkInterfaceID( - apinetNic.Namespace, - apinetNic.Name, - apinetNic.Spec.NodeRef.Name, - apinetNic.UID, - ), - HostDevice: hostDev, - }, nil - } - log.V(1).Info("Waiting for apinet network interface to become ready") + var hostDev *providernetworkinterface.HostDevice apinetNicKey := client.ObjectKeyFromObject(apinetNic) if err := wait.PollUntilContextTimeout(ctx, 50*time.Millisecond, 5*time.Second, true, func(ctx context.Context) (done bool, err error) { if err := p.host.APINetClient().Get(ctx, apinetNicKey, apinetNic); err != nil { @@ -180,17 +163,12 @@ func (p *Plugin) Apply(ctx context.Context, spec *api.NetworkInterfaceSpec, mach return nil, fmt.Errorf("error waiting for nic to become ready: %w", err) } - // Fetch the updated object to get the ID or any other updated fields - if err := p.host.APINetClient().Get(ctx, apinetNicKey, apinetNic); err != nil { - return nil, fmt.Errorf("error fetching updated apinet network interface: %w", err) - } - - log.V(1).Info("Host device is ready", "HostDevice", hostDev) - nicIPs := make([]net.IP, 0, len(apinetNic.Spec.IPs)) + nicIPs := make([]string, 0, len(apinetNic.Spec.IPs)) for _, apinetNicIP := range apinetNic.Spec.IPs { // TODO: do proper IP type conversion here - nicIPs = append(nicIPs, net.ParseIP(apinetNicIP.String())) + nicIPs = append(nicIPs, apinetNicIP.String()) } + log.V(1).Info("Host device is ready", "HostDevice", hostDev, "IPs", nicIPs) return &providernetworkinterface.NetworkInterface{ Handle: provider.GetNetworkInterfaceID( apinetNic.Namespace, diff --git a/pkg/plugins/networkinterface/plugins.go b/pkg/plugins/networkinterface/plugins.go index 590f85a1..5b9fd6d6 100644 --- a/pkg/plugins/networkinterface/plugins.go +++ b/pkg/plugins/networkinterface/plugins.go @@ -6,7 +6,6 @@ package networkinterface import ( "context" "fmt" - "net" computev1alpha1 "github.com/ironcore-dev/ironcore/api/compute/v1alpha1" networkingv1alpha1 "github.com/ironcore-dev/ironcore/api/networking/v1alpha1" @@ -101,7 +100,7 @@ type NetworkInterface struct { HostDevice *HostDevice Isolated *Isolated ProviderNetwork *ProviderNetwork - IPs []net.IP + IPs []string } type Isolated struct{} diff --git a/provider/server/machine.go b/provider/server/machine.go index 202f5acf..0ca87480 100644 --- a/provider/server/machine.go +++ b/provider/server/machine.go @@ -138,15 +138,11 @@ func (s *Server) getIRINICStatus(machine *api.Machine) ([]*iri.NetworkInterfaceS return nil, fmt.Errorf("failed to get nic state: %w", err) } - nicIPs := make([]string, 0, len(nic.IPs)) - for _, ip := range nic.IPs { - nicIPs = append(nicIPs, ip.String()) - } nics = append(nics, &iri.NetworkInterfaceStatus{ Name: nic.Name, Handle: nic.Handle, State: state, - Ips: nicIPs, + Ips: nic.IPs, }) }