Skip to content

Commit

Permalink
Find BootMACAddress from any machine network
Browse files Browse the repository at this point in the history
Don't restrict ourselves to the first machine network when looking for
an interface on a machine network to set the BootMACAddress.
  • Loading branch information
zaneb committed Sep 3, 2024
1 parent f4fcd28 commit f3051bd
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions internal/provider/baremetal/installConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,24 @@ func (p baremetalProvider) AddPlatformToInstallConfig(
return err
}

InterfaceSearch:
for _, iface := range inventory.Interfaces {
// We are looking for the NIC that matches the first Machine Network configured
// for the cluster. This is to ensure that BootMACAddress belongs to the NIC that
// is really used and not to any fake interface even if this interface has IPs.
ipAddressses := append(iface.IPV4Addresses, iface.IPV6Addresses...)
for _, ip := range ipAddressses {
overlap, _ := network.NetworksOverlap(ip, string(cluster.MachineNetworks[0].Cidr))
if overlap {
hosts[yamlHostIdx].BootMACAddress = iface.MacAddress
break
for _, machineNetwork := range cluster.MachineNetworks {
overlap, _ := network.NetworksOverlap(ip, string(machineNetwork.Cidr))
if overlap {
hosts[yamlHostIdx].BootMACAddress = iface.MacAddress
break InterfaceSearch
}
}
}
}
if hosts[yamlHostIdx].BootMACAddress == "" {
err = errors.Errorf("Failed to find a network interface matching machine network (%s) for host %s",
cluster.MachineNetworks[0].Cidr,
err = errors.Errorf("Failed to find a network interface matching machine networks for host %s",
hostutil.GetHostnameForMsg(host),
)
p.Log.Error(err)
Expand Down

0 comments on commit f3051bd

Please sign in to comment.