Skip to content

Commit 7cef02e

Browse files
committed
address review comments
1 parent 1a1b513 commit 7cef02e

File tree

5 files changed

+20
-22
lines changed

5 files changed

+20
-22
lines changed

api/v1alpha1/server_types.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,13 @@ type NetworkInterface struct {
290290
// +required
291291
Name string `json:"name"`
292292

293+
// IP is the IP address assigned to the network interface.
294+
// Deprecated: Use IPs instead. Kept for backward compatibility, always nil.
295+
// +kubebuilder:validation:Type=string
296+
// +kubebuilder:validation:Schemaless
297+
// +optional
298+
IP *IP `json:"ip,omitempty"`
299+
293300
// IPs is a list of IP addresses (both IPv4 and IPv6) assigned to the network interface.
294301
// +optional
295302
IPs []IP `json:"ips,omitempty"`

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/metal.ironcore.dev_servers.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,11 @@ spec:
465465
description: CarrierStatus is the operational carrier status
466466
of the network interface.
467467
type: string
468+
ip:
469+
description: |-
470+
IP is the IP address assigned to the network interface.
471+
Deprecated: Use IPs instead. Kept for backward compatibility, always nil.
472+
type: string
468473
ips:
469474
description: IPs is a list of IP addresses (both IPv4 and IPv6)
470475
assigned to the network interface.

internal/controller/server_controller.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -836,11 +836,7 @@ func (r *ServerReconciler) extractServerDetailsFromRegistry(ctx context.Context,
836836
}
837837
}
838838

839-
// Set the IPs field with all collected IP addresses
840-
if len(allIPs) > 0 {
841-
nic.IPs = allIPs
842-
}
843-
839+
nic.IPs = allIPs
844840
nics = append(nics, nic)
845841
}
846842

internal/probe/networking.go

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ func collectNetworkData() ([]registry.NetworkInterface, error) {
4040
}
4141

4242
addrs, err := iface.Addrs()
43-
if err != nil {
44-
// If we can't get addresses, still include the interface with empty IP
43+
// If we can't get addresses or interface has no addresses, still include it with empty IP
44+
if err != nil || len(addrs) == 0 {
4545
networkInterface := registry.NetworkInterface{
4646
Name: iface.Name,
4747
IPAddresses: []string{},
@@ -50,21 +50,7 @@ func collectNetworkData() ([]registry.NetworkInterface, error) {
5050
}
5151
networkInterfaces = append(networkInterfaces, networkInterface)
5252
continue
53-
}
54-
55-
// If interface has no addresses, still include it
56-
if len(addrs) == 0 {
57-
networkInterface := registry.NetworkInterface{
58-
Name: iface.Name,
59-
IPAddresses: []string{},
60-
MACAddress: iface.HardwareAddr.String(),
61-
CarrierStatus: status,
62-
}
63-
networkInterfaces = append(networkInterfaces, networkInterface)
64-
continue
65-
}
66-
67-
// Collect all IP addresses (both IPv4 and IPv6) in a single slice
53+
} // Collect all IP addresses (both IPv4 and IPv6) in a single slice
6854
var ipAddresses []string
6955

7056
for _, addr := range addrs {

0 commit comments

Comments
 (0)