Skip to content

Commit 5e207d3

Browse files
author
Rahul Ganesh
committed
Default hardware MAC in iso mount workflows
For ISO bootmode, the controller required a placeHolder ":macAddress" to be present in the ISOURL which would then later be replaced to the MAC address of the actual hardware during the workflow creation time. Default the logic to append hardware MAC before the ISO file name by default without any placeholder, as we are doing it anyways right now and this slightly alleviates the user experience. Signed-off-by: Rahul Ganesh <[email protected]>
1 parent 97ed2ed commit 5e207d3

File tree

4 files changed

+17
-10
lines changed

4 files changed

+17
-10
lines changed

api/v1beta1/tinkerbellmachine_types.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,13 @@ type BootOptions struct {
8989
// for getting the associated hardware into a CDROM booting state.
9090
// A HardwareRef that contains a spec.BmcRef must be provided.
9191
//
92-
// The format of the ISOURL must be http://$IP:$Port/iso/:macAddress/hook.iso
92+
// The format of the ISOURL must be http://$IP:$Port/iso/hook.iso
9393
// The name of the ISO file must have the .iso extension, but the name can be anything.
9494
// The $IP and $Port should generally point to the IP and Port of the Smee server
9595
// as this is where the ISO patching endpoint lives.
96-
// The ":macAddress" is a placeholder for the MAC address of the hardware and
97-
// should be provided exactly as is: ":macAddress".
96+
// The controller will append the MAC address of the hardware in the ISO URL
97+
// right before the iso file name in the URL.
98+
// For ex. the above format would be replaced to http://$IP:$Port/iso/<macAddress>/hook.iso
9899
// +optional
99100
// +kubebuilder:validation:Format=url
100101
ISOURL string `json:"isoURL,omitempty"`

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,13 @@ spec:
8181
for getting the associated hardware into a CDROM booting state.
8282
A HardwareRef that contains a spec.BmcRef must be provided.
8383
84-
The format of the ISOURL must be http://$IP:$Port/iso/:macAddress/hook.iso
84+
The format of the ISOURL must be http://$IP:$Port/iso/hook.iso
8585
The name of the ISO file must have the .iso extension, but the name can be anything.
8686
The $IP and $Port should generally point to the IP and Port of the Smee server
8787
as this is where the ISO patching endpoint lives.
88-
The ":macAddress" is a placeholder for the MAC address of the hardware and
89-
should be provided exactly as is: ":macAddress".
88+
The controller will append the MAC address of the hardware in the ISO URL
89+
right before the iso file name in the URL.
90+
For ex. the above format would be replaced to http://$IP:$Port/iso/<macAddress>/hook.iso
9091
format: url
9192
type: string
9293
type: object

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,13 @@ spec:
7171
for getting the associated hardware into a CDROM booting state.
7272
A HardwareRef that contains a spec.BmcRef must be provided.
7373
74-
The format of the ISOURL must be http://$IP:$Port/iso/:macAddress/hook.iso
74+
The format of the ISOURL must be http://$IP:$Port/iso/hook.iso
7575
The name of the ISO file must have the .iso extension, but the name can be anything.
7676
The $IP and $Port should generally point to the IP and Port of the Smee server
7777
as this is where the ISO patching endpoint lives.
78-
The ":macAddress" is a placeholder for the MAC address of the hardware and
79-
should be provided exactly as is: ":macAddress".
78+
The controller will append the MAC address of the hardware in the ISO URL
79+
right before the iso file name in the URL.
80+
For ex. the above format would be replaced to http://$IP:$Port/iso/<macAddress>/hook.iso
8081
format: url
8182
type: string
8283
type: object

controller/machine/workflow.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"errors"
55
"fmt"
66
"net/url"
7+
"path"
78
"strings"
89

910
"github.com/tinkerbell/cluster-api-provider-tinkerbell/api/v1beta1"
@@ -82,7 +83,10 @@ func (scope *machineReconcileScope) createWorkflow(hw *tinkv1.Hardware) error {
8283
return fmt.Errorf("boot option isoURL is not parse-able: %w", err)
8384
}
8485

85-
u.Path = strings.Replace(u.Path, ":macAddress", strings.Replace(hw.Spec.Metadata.Instance.ID, ":", "-", 5), 1)
86+
urlPath, file := path.Split(u.Path)
87+
urlPath = strings.TrimRight(urlPath, "/")
88+
u.Path = fmt.Sprintf("%s/%s/%s", urlPath, strings.Replace(hw.Spec.Metadata.Instance.ID, ":", "-", 5), file)
89+
8690
workflow.Spec.BootOptions.ISOURL = u.String()
8791
workflow.Spec.BootOptions.BootMode = tinkv1.BootMode("iso")
8892
}

0 commit comments

Comments
 (0)