Skip to content

Commit a5ace1a

Browse files
Handle ISO url properly:
Workflows and Smee require the ISO url mac address in dash notation. CAPT needs to provide a placeholder for this value so that it can be added by the reconciler. Signed-off-by: Jacob Weinstock <[email protected]>
1 parent f39a5f6 commit a5ace1a

File tree

4 files changed

+30
-4
lines changed

4 files changed

+30
-4
lines changed

api/v1beta1/tinkerbellmachine_types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,17 @@ type BootOptions struct {
8888
// When this field is set, the controller will create a job.bmc.tinkerbell.org object
8989
// for getting the associated hardware into a CDROM booting state.
9090
// A HardwareRef that contains a spec.BmcRef must be provided.
91+
// The format of the ISOURL must be http://$IP:$Port/iso/:macAddress/hook.iso
92+
// The name of the ISO file must have the .iso extension, but the name can be anything.
93+
// The $IP and $Port should generally point to the IP and Port of the Smee server as this is where
94+
// the ISO patching endpoint lives.
95+
// The ":macAddress" is a placeholder for the MAC address of the hardware and should be provided exactly as is: ":macAddress".
9196
// +optional
9297
// +kubebuilder:validation:Format=url
9398
ISOURL string `json:"isoURL,omitempty"`
9499

95100
// BootMode is the type of booting that will be done.
101+
// Must be one of "none", "netboot", or "iso".
96102
// +optional
97103
// +kubebuilder:validation:Enum=none;netboot;iso
98104
BootMode BootMode `json:"bootMode,omitempty"`

config/crd/bases/infrastructure.cluster.x-k8s.io_tinkerbellmachines.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ spec:
6666
description: BootOptions are options that control the booting of Hardware.
6767
properties:
6868
bootMode:
69-
description: BootMode is the type of booting that will be done.
69+
description: |-
70+
BootMode is the type of booting that will be done.
71+
Must be one of "none", "netboot", or "iso".
7072
enum:
7173
- none
7274
- netboot
@@ -78,6 +80,11 @@ spec:
7880
When this field is set, the controller will create a job.bmc.tinkerbell.org object
7981
for getting the associated hardware into a CDROM booting state.
8082
A HardwareRef that contains a spec.BmcRef must be provided.
83+
The format of the ISOURL must be http://$IP:$Port/iso/:macAddress/hook.iso
84+
The name of the ISO file must have the .iso extension, but the name can be anything.
85+
The $IP and $Port should generally point to the IP and Port of the Smee server as this is where
86+
the ISO patching endpoint lives.
87+
The ":macAddress" is a placeholder for the MAC address of the hardware and should be provided exactly as is: ":macAddress".
8188
format: url
8289
type: string
8390
type: object

config/crd/bases/infrastructure.cluster.x-k8s.io_tinkerbellmachinetemplates.yaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ spec:
5656
of Hardware.
5757
properties:
5858
bootMode:
59-
description: BootMode is the type of booting that will
60-
be done.
59+
description: |-
60+
BootMode is the type of booting that will be done.
61+
Must be one of "none", "netboot", or "iso".
6162
enum:
6263
- none
6364
- netboot
@@ -69,6 +70,11 @@ spec:
6970
When this field is set, the controller will create a job.bmc.tinkerbell.org object
7071
for getting the associated hardware into a CDROM booting state.
7172
A HardwareRef that contains a spec.BmcRef must be provided.
73+
The format of the ISOURL must be http://$IP:$Port/iso/:macAddress/hook.iso
74+
The name of the ISO file must have the .iso extension, but the name can be anything.
75+
The $IP and $Port should generally point to the IP and Port of the Smee server as this is where
76+
the ISO patching endpoint lives.
77+
The ":macAddress" is a placeholder for the MAC address of the hardware and should be provided exactly as is: ":macAddress".
7278
format: url
7379
type: string
7480
type: object

controller/machine/workflow.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package machine
33
import (
44
"errors"
55
"fmt"
6+
"net/url"
7+
"strings"
68

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

@@ -76,7 +78,12 @@ func (scope *machineReconcileScope) createWorkflow(hw *tinkv1.Hardware) error {
7678
}
7779

7880
workflow.Spec.BootOptions.BootMode = tinkv1.BootMode("iso")
79-
workflow.Spec.BootOptions.ISOURL = scope.tinkerbellMachine.Spec.BootOptions.ISOURL
81+
u, err := url.Parse(scope.tinkerbellMachine.Spec.BootOptions.ISOURL)
82+
if err != nil {
83+
return fmt.Errorf("boot option isoURL is not parse-able: %w", err)
84+
}
85+
u.Path = strings.Replace(u.Path, ":macAddress", strings.Replace(hw.Spec.Metadata.Instance.ID, ":", "-", 5), 1)
86+
workflow.Spec.BootOptions.ISOURL = u.String()
8087
}
8188
}
8289

0 commit comments

Comments
 (0)