Skip to content

Commit 3a273f9

Browse files
committed
baremetal: use external_http_url for ipv6 BMCs
1 parent bc3eb1c commit 3a273f9

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

data/data/bootstrap/baremetal/files/etc/containers/systemd/metal3-baremetal-operator.container

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Environment="INSPECTOR_HTPASSWD=${IRONIC_HTPASSWD}"
2020
Environment="IRONIC_KERNEL_PARAMS=${IRONIC_KERNEL_PARAMS}"
2121
Environment="HTTP_PORT=${HTTP_PORT}"
2222
Environment="IRONIC_ENDPOINT=${IRONIC_ENDPOINT}"
23+
Environment="IRONIC_EXTERNAL_URL_V6=${IRONIC_EXTERNAL_URL_V6}"
2324

2425
[Service]
2526
EnvironmentFile=/etc/metal3.env
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
AUTH_DIR=/opt/metal3/auth
22
IRONIC_ENDPOINT="http://{{.PlatformData.BareMetal.IronicUsername}}:{{.PlatformData.BareMetal.IronicPassword}}@localhost:6385/v1"
3+
IRONIC_EXTERNAL_URL_V6="{{.PlatformData.BareMetal.ExternalURLv6}}"

data/data/bootstrap/baremetal/systemd/units/build-ironic-env.service.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ After=network-online.target crio.service release-image.service
88
EnvironmentFile=/etc/ironic-network.env
99
Environment="PROVISIONING_MAC={{.PlatformData.BareMetal.ProvisioningInterfaceMAC}}"
1010
Environment="PROVISIONING_NETWORK_TYPE={{.PlatformData.BareMetal.ProvisioningNetwork}}"
11-
Environment="IRONIC_IP={{.PlatformData.BareMetal.APIVIP}}"
11+
Environment="IRONIC_IP={{index .PlatformData.BareMetal.APIVIPs 0}}"
1212
Environment="IRONIC_USERNAME={{.PlatformData.BareMetal.IronicUsername}}"
1313
ExecStart=/usr/local/bin/build-ironic-env.sh
1414
Type=oneshot

pkg/asset/ignition/bootstrap/baremetal/template.go

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import (
55
"net"
66
"strings"
77

8+
utilsnet "k8s.io/utils/net"
9+
810
"github.com/openshift/installer/pkg/types"
911
"github.com/openshift/installer/pkg/types/baremetal"
1012
)
@@ -51,7 +53,7 @@ type TemplateData struct {
5153
ClusterOSImage string
5254

5355
// API VIP for use by ironic during bootstrap.
54-
APIVIP string
56+
APIVIPs []string
5557

5658
// Hosts is the information needed to create the objects in Ironic.
5759
Hosts []*baremetal.Host
@@ -71,6 +73,25 @@ type TemplateData struct {
7173
ExternalSubnetCIDR int
7274

7375
ExternalMACAddress string
76+
77+
// ExternalURLv6 is a callback URL for the node if the node and the BMC use different network families
78+
ExternalURLv6 string
79+
}
80+
81+
func externalURLs(apiVIPs []string) (externalURLv4 string, externalURLv6 string) {
82+
if len(apiVIPs) > 1 {
83+
// IPv6 BMCs may not be able to reach IPv4 servers, use the right callback URL for them.
84+
// Warning: when backporting to 4.12 or earlier, change the port to 80!
85+
externalURL := fmt.Sprintf("http://%s/", net.JoinHostPort(apiVIPs[1], "6180"))
86+
if utilsnet.IsIPv6String(apiVIPs[1]) {
87+
externalURLv6 = externalURL
88+
}
89+
if utilsnet.IsIPv4String(apiVIPs[1]) {
90+
externalURLv4 = externalURL
91+
}
92+
}
93+
94+
return
7495
}
7596

7697
// GetTemplateData returns platform-specific data for bootstrap templates.
@@ -86,8 +107,12 @@ func GetTemplateData(config *baremetal.Platform, networks []types.MachineNetwork
86107
templateData.ExternalStaticDNS = config.BootstrapExternalStaticDNS
87108
templateData.ExternalMACAddress = config.ExternalMACAddress
88109

110+
_, externalURLv6 := externalURLs(config.APIVIPs)
111+
112+
templateData.ExternalURLv6 = externalURLv6
113+
89114
if len(config.APIVIPs) > 0 {
90-
templateData.APIVIP = config.APIVIPs[0]
115+
templateData.APIVIPs = config.APIVIPs
91116
templateData.BaremetalEndpointOverride = fmt.Sprintf("http://%s/v1", net.JoinHostPort(config.APIVIPs[0], "6385"))
92117
templateData.BaremetalIntrospectionEndpointOverride = fmt.Sprintf("http://%s/v1", net.JoinHostPort(config.APIVIPs[0], "5050"))
93118
}

0 commit comments

Comments
 (0)