Skip to content

Commit

Permalink
Merge pull request openstack-k8s-operators#1047 from jpodivin/baremet…
Browse files Browse the repository at this point in the history
…alipambreak

Fail baremetal deployment if IPAM isn't configured
  • Loading branch information
openshift-merge-bot[bot] authored Sep 4, 2024
2 parents 37f1274 + 4d0f4c5 commit 94cec43
Showing 1 changed file with 17 additions and 20 deletions.
37 changes: 17 additions & 20 deletions pkg/dataplane/baremetal.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,29 +70,26 @@ func DeployBaremetalSet(
ipSet, ok := ipSets[hostName]
instanceSpec := baremetalSet.Spec.BaremetalHosts[hostName]
if !ok {
// TODO: Change this to raise an error instead.
// NOTE(hjensas): Hardcode /24 here, this used to rely on
// baremetalSet.Spec.CtlplaneNetmask's default value ("255.255.255.0").
utils.LogForObject(helper, "IPAM Not configured for use, skipping", instance)
instanceSpec.CtlPlaneIP = fmt.Sprintf("%s/24", node.Ansible.AnsibleHost)
} else {
for _, res := range ipSet.Status.Reservation {
if strings.ToLower(string(res.Network)) == dataplanev1.CtlPlaneNetwork {
_, ipNet, err := net.ParseCIDR(res.Cidr)
if err != nil {
return err
}
ipPrefix, _ := ipNet.Mask.Size()
instanceSpec.CtlPlaneIP = fmt.Sprintf("%s/%d", res.Address, ipPrefix)
if res.Gateway == nil {
return fmt.Errorf("%s gateway is missing", dataplanev1.CtlPlaneNetwork)
}
baremetalSet.Spec.CtlplaneGateway = *res.Gateway
baremetalSet.Spec.BootstrapDNS = dnsAddresses
baremetalSet.Spec.DNSSearchDomains = []string{res.DNSDomain}
err := fmt.Errorf("no IPSet found for host: %s", hostName)
return err
}
for _, res := range ipSet.Status.Reservation {
if strings.ToLower(string(res.Network)) == dataplanev1.CtlPlaneNetwork {
_, ipNet, err := net.ParseCIDR(res.Cidr)
if err != nil {
return err
}
ipPrefix, _ := ipNet.Mask.Size()
instanceSpec.CtlPlaneIP = fmt.Sprintf("%s/%d", res.Address, ipPrefix)
if res.Gateway == nil {
return fmt.Errorf("%s gateway is missing", dataplanev1.CtlPlaneNetwork)
}
baremetalSet.Spec.CtlplaneGateway = *res.Gateway
baremetalSet.Spec.BootstrapDNS = dnsAddresses
baremetalSet.Spec.DNSSearchDomains = []string{res.DNSDomain}
}
}

baremetalSet.Spec.BaremetalHosts[hostName] = instanceSpec

}
Expand Down

0 comments on commit 94cec43

Please sign in to comment.