Skip to content

Commit 4d0f4c5

Browse files
committed
Fail baremetal deployment if IPAM isn't configured
Signed-off-by: Jiri Podivin <[email protected]>
1 parent 37f1274 commit 4d0f4c5

File tree

1 file changed

+17
-20
lines changed

1 file changed

+17
-20
lines changed

pkg/dataplane/baremetal.go

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -70,29 +70,26 @@ func DeployBaremetalSet(
7070
ipSet, ok := ipSets[hostName]
7171
instanceSpec := baremetalSet.Spec.BaremetalHosts[hostName]
7272
if !ok {
73-
// TODO: Change this to raise an error instead.
74-
// NOTE(hjensas): Hardcode /24 here, this used to rely on
75-
// baremetalSet.Spec.CtlplaneNetmask's default value ("255.255.255.0").
76-
utils.LogForObject(helper, "IPAM Not configured for use, skipping", instance)
77-
instanceSpec.CtlPlaneIP = fmt.Sprintf("%s/24", node.Ansible.AnsibleHost)
78-
} else {
79-
for _, res := range ipSet.Status.Reservation {
80-
if strings.ToLower(string(res.Network)) == dataplanev1.CtlPlaneNetwork {
81-
_, ipNet, err := net.ParseCIDR(res.Cidr)
82-
if err != nil {
83-
return err
84-
}
85-
ipPrefix, _ := ipNet.Mask.Size()
86-
instanceSpec.CtlPlaneIP = fmt.Sprintf("%s/%d", res.Address, ipPrefix)
87-
if res.Gateway == nil {
88-
return fmt.Errorf("%s gateway is missing", dataplanev1.CtlPlaneNetwork)
89-
}
90-
baremetalSet.Spec.CtlplaneGateway = *res.Gateway
91-
baremetalSet.Spec.BootstrapDNS = dnsAddresses
92-
baremetalSet.Spec.DNSSearchDomains = []string{res.DNSDomain}
73+
err := fmt.Errorf("no IPSet found for host: %s", hostName)
74+
return err
75+
}
76+
for _, res := range ipSet.Status.Reservation {
77+
if strings.ToLower(string(res.Network)) == dataplanev1.CtlPlaneNetwork {
78+
_, ipNet, err := net.ParseCIDR(res.Cidr)
79+
if err != nil {
80+
return err
81+
}
82+
ipPrefix, _ := ipNet.Mask.Size()
83+
instanceSpec.CtlPlaneIP = fmt.Sprintf("%s/%d", res.Address, ipPrefix)
84+
if res.Gateway == nil {
85+
return fmt.Errorf("%s gateway is missing", dataplanev1.CtlPlaneNetwork)
9386
}
87+
baremetalSet.Spec.CtlplaneGateway = *res.Gateway
88+
baremetalSet.Spec.BootstrapDNS = dnsAddresses
89+
baremetalSet.Spec.DNSSearchDomains = []string{res.DNSDomain}
9490
}
9591
}
92+
9693
baremetalSet.Spec.BaremetalHosts[hostName] = instanceSpec
9794

9895
}

0 commit comments

Comments
 (0)