Skip to content

Handle ISO url properly: #422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 27, 2024
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
8 changes: 8 additions & 0 deletions api/v1beta1/tinkerbellmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,19 @@ type BootOptions struct {
// When this field is set, the controller will create a job.bmc.tinkerbell.org object
// for getting the associated hardware into a CDROM booting state.
// A HardwareRef that contains a spec.BmcRef must be provided.
//
// The format of the ISOURL must be http://$IP:$Port/iso/:macAddress/hook.iso
// The name of the ISO file must have the .iso extension, but the name can be anything.
// The $IP and $Port should generally point to the IP and Port of the Smee server
// as this is where the ISO patching endpoint lives.
// The ":macAddress" is a placeholder for the MAC address of the hardware and
// should be provided exactly as is: ":macAddress".
// +optional
// +kubebuilder:validation:Format=url
ISOURL string `json:"isoURL,omitempty"`

// BootMode is the type of booting that will be done.
// Must be one of "none", "netboot", or "iso".
// +optional
// +kubebuilder:validation:Enum=none;netboot;iso
BootMode BootMode `json:"bootMode,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ spec:
description: BootOptions are options that control the booting of Hardware.
properties:
bootMode:
description: BootMode is the type of booting that will be done.
description: |-
BootMode is the type of booting that will be done.
Must be one of "none", "netboot", or "iso".
enum:
- none
- netboot
Expand All @@ -78,6 +80,13 @@ spec:
When this field is set, the controller will create a job.bmc.tinkerbell.org object
for getting the associated hardware into a CDROM booting state.
A HardwareRef that contains a spec.BmcRef must be provided.

The format of the ISOURL must be http://$IP:$Port/iso/:macAddress/hook.iso
The name of the ISO file must have the .iso extension, but the name can be anything.
The $IP and $Port should generally point to the IP and Port of the Smee server
as this is where the ISO patching endpoint lives.
The ":macAddress" is a placeholder for the MAC address of the hardware and
should be provided exactly as is: ":macAddress".
format: url
type: string
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ spec:
of Hardware.
properties:
bootMode:
description: BootMode is the type of booting that will
be done.
description: |-
BootMode is the type of booting that will be done.
Must be one of "none", "netboot", or "iso".
enum:
- none
- netboot
Expand All @@ -69,6 +70,13 @@ spec:
When this field is set, the controller will create a job.bmc.tinkerbell.org object
for getting the associated hardware into a CDROM booting state.
A HardwareRef that contains a spec.BmcRef must be provided.

The format of the ISOURL must be http://$IP:$Port/iso/:macAddress/hook.iso
The name of the ISO file must have the .iso extension, but the name can be anything.
The $IP and $Port should generally point to the IP and Port of the Smee server
as this is where the ISO patching endpoint lives.
The ":macAddress" is a placeholder for the MAC address of the hardware and
should be provided exactly as is: ":macAddress".
format: url
type: string
type: object
Expand Down
10 changes: 9 additions & 1 deletion controller/machine/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package machine
import (
"errors"
"fmt"
"net/url"
"strings"

"github.com/tinkerbell/cluster-api-provider-tinkerbell/api/v1beta1"

Expand Down Expand Up @@ -75,8 +77,14 @@ func (scope *machineReconcileScope) createWorkflow(hw *tinkv1.Hardware) error {
return errISOBootURLRequired
}

u, err := url.Parse(scope.tinkerbellMachine.Spec.BootOptions.ISOURL)
if err != nil {
return fmt.Errorf("boot option isoURL is not parse-able: %w", err)
}

u.Path = strings.Replace(u.Path, ":macAddress", strings.Replace(hw.Spec.Metadata.Instance.ID, ":", "-", 5), 1)
workflow.Spec.BootOptions.ISOURL = u.String()
workflow.Spec.BootOptions.BootMode = tinkv1.BootMode("iso")
workflow.Spec.BootOptions.ISOURL = scope.tinkerbellMachine.Spec.BootOptions.ISOURL
}
}

Expand Down
Loading