Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions provisioning/image_customization.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ const (
deployInitrdFile = imageSharedDir + "/ironic-python-agent.initramfs"
deployKernelEnvVar = "DEPLOY_KERNEL"
deployKernelFile = imageSharedDir + "/ironic-python-agent.kernel"
ironicRootfsEnvVar = "IRONIC_ROOTFS_URL"
ironicRootfsFile = "ironic-python-agent.rootfs"
imageCustomizationConfigName = "metal3-image-customization-config"
ironicAgentPullSecret = "ironic-agent-pull-secret" // #nosec G101
ironicAgentPullSecretPath = "/run/secrets/pull-secret" // #nosec G101
Expand Down Expand Up @@ -129,6 +131,16 @@ func getUrlFromIP(ipAddrs []string, port int) string {
return strings.Join(result, ",")
}

func getRootfsURL(ironicIPs []string) string {
for _, ip := range ironicIPs {
if ip != "" {
return fmt.Sprintf("http://%s/images/%s",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general looks good to me, just wondering if it's ok to hardcode the http (do we have cases where this would be https? 🤔

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https support for images is WIP upstream still

net.JoinHostPort(ip, baremetalHttpPort), ironicRootfsFile)
}
}
return ""
}

func createImageCustomizationContainer(images *Images, info *ProvisioningInfo, ironicIPs []string) corev1.Container {
noProxy := ironicIPs
envVars := envWithProxy(info.Proxy, []corev1.EnvVar{}, noProxy)
Expand Down Expand Up @@ -200,6 +212,10 @@ func createImageCustomizationContainer(images *Images, info *ProvisioningInfo, i
Name: containerUserCaBundleEnvVar,
Value: containerUserCaBundlePath,
},
corev1.EnvVar{
Name: ironicRootfsEnvVar,
Value: getRootfsURL(ironicIPs),
},
buildSSHKeyEnvVar(info.SSHKey)),
Ports: []corev1.ContainerPort{
{
Expand Down
5 changes: 5 additions & 0 deletions provisioning/image_customization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ func TestNewImageCustomizationContainer(t *testing.T) {
{Name: "IP_OPTIONS", Value: "ip=dhcp"},
{Name: "ADDITIONAL_NTP_SERVERS", Value: ""},
{Name: "CA_BUNDLE", Value: "/etc/pki/ca-trust/source/anchors/openshift-config-user-ca-bundle.crt"},
{Name: "IRONIC_ROOTFS_URL", Value: "http://192.168.0.2:6180/images/ironic-python-agent.rootfs"},
{Name: "IRONIC_RAMDISK_SSH_KEY", Value: "sshkey"},
},
VolumeMounts: expectedVolumeMounts,
Expand All @@ -94,6 +95,7 @@ func TestNewImageCustomizationContainer(t *testing.T) {
{Name: "IP_OPTIONS", Value: "ip=dhcp"},
{Name: "ADDITIONAL_NTP_SERVERS", Value: ""},
{Name: "CA_BUNDLE", Value: "/etc/pki/ca-trust/source/anchors/openshift-config-user-ca-bundle.crt"},
{Name: "IRONIC_ROOTFS_URL", Value: "http://192.168.0.2:6180/images/ironic-python-agent.rootfs"},
{Name: "IRONIC_RAMDISK_SSH_KEY", Value: "sshkey"},
},
VolumeMounts: expectedVolumeMounts,
Expand All @@ -119,6 +121,7 @@ func TestNewImageCustomizationContainer(t *testing.T) {
{Name: "IP_OPTIONS", Value: "ip=dhcp"},
{Name: "ADDITIONAL_NTP_SERVERS", Value: ""},
{Name: "CA_BUNDLE", Value: "/etc/pki/ca-trust/source/anchors/openshift-config-user-ca-bundle.crt"},
{Name: "IRONIC_ROOTFS_URL", Value: "http://192.168.0.2:6180/images/ironic-python-agent.rootfs"},
{Name: "IRONIC_RAMDISK_SSH_KEY", Value: "sshkey"},
},
VolumeMounts: expectedVolumeMounts,
Expand All @@ -141,6 +144,7 @@ func TestNewImageCustomizationContainer(t *testing.T) {
{Name: "IP_OPTIONS", Value: "ip=dhcp"},
{Name: "ADDITIONAL_NTP_SERVERS", Value: "192.168.1.252,192.168.1.253"},
{Name: "CA_BUNDLE", Value: "/etc/pki/ca-trust/source/anchors/openshift-config-user-ca-bundle.crt"},
{Name: "IRONIC_ROOTFS_URL", Value: "http://192.168.0.2:6180/images/ironic-python-agent.rootfs"},
{Name: "IRONIC_RAMDISK_SSH_KEY", Value: "sshkey"},
},
VolumeMounts: expectedVolumeMounts,
Expand All @@ -164,6 +168,7 @@ func TestNewImageCustomizationContainer(t *testing.T) {
{Name: "IP_OPTIONS", Value: "ip=dhcp"},
{Name: "ADDITIONAL_NTP_SERVERS", Value: ""},
{Name: "CA_BUNDLE", Value: "/etc/pki/ca-trust/source/anchors/openshift-config-user-ca-bundle.crt"},
{Name: "IRONIC_ROOTFS_URL", Value: "http://192.168.0.2:6180/images/ironic-python-agent.rootfs"},
{Name: "IRONIC_RAMDISK_SSH_KEY", Value: "sshkey"},
},
VolumeMounts: expectedVolumeMounts,
Expand Down