Skip to content

Commit fb1ed00

Browse files
Merge pull request #422 from jacobweinstock/fix-iso-url
Handle ISO url properly: ## Description <!--- Please describe what this PR is going to change --> 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. ## Why is this needed <!--- Link to issue you have raised --> Fixes: # ## How Has This Been Tested? <!--- Please describe in detail how you tested your changes. --> <!--- Include details of your testing environment, and the tests you ran to --> <!--- see how your change affects other areas of the code, etc. --> ## How are existing users impacted? What migration steps/scripts do we need? <!--- Fixes a bug, unblocks installation, removes a component of the stack etc --> <!--- Requires a DB migration script, etc. --> ## Checklist: I have: - [ ] updated the documentation and/or roadmap (if required) - [ ] added unit or e2e tests - [ ] provided instructions on how to upgrade
2 parents f39a5f6 + 23b88d6 commit fb1ed00

4 files changed

+37
-4
lines changed

api/v1beta1/tinkerbellmachine_types.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,19 @@ 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+
//
92+
// The format of the ISOURL must be http://$IP:$Port/iso/:macAddress/hook.iso
93+
// The name of the ISO file must have the .iso extension, but the name can be anything.
94+
// The $IP and $Port should generally point to the IP and Port of the Smee server
95+
// 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".
9198
// +optional
9299
// +kubebuilder:validation:Format=url
93100
ISOURL string `json:"isoURL,omitempty"`
94101

95102
// BootMode is the type of booting that will be done.
103+
// Must be one of "none", "netboot", or "iso".
96104
// +optional
97105
// +kubebuilder:validation:Enum=none;netboot;iso
98106
BootMode BootMode `json:"bootMode,omitempty"`

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

Lines changed: 10 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,13 @@ 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+
84+
The format of the ISOURL must be http://$IP:$Port/iso/:macAddress/hook.iso
85+
The name of the ISO file must have the .iso extension, but the name can be anything.
86+
The $IP and $Port should generally point to the IP and Port of the Smee server
87+
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".
8190
format: url
8291
type: string
8392
type: object

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

Lines changed: 10 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,13 @@ 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+
74+
The format of the ISOURL must be http://$IP:$Port/iso/:macAddress/hook.iso
75+
The name of the ISO file must have the .iso extension, but the name can be anything.
76+
The $IP and $Port should generally point to the IP and Port of the Smee server
77+
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".
7280
format: url
7381
type: string
7482
type: object

controller/machine/workflow.go

Lines changed: 9 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

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

80+
u, err := url.Parse(scope.tinkerbellMachine.Spec.BootOptions.ISOURL)
81+
if err != nil {
82+
return fmt.Errorf("boot option isoURL is not parse-able: %w", err)
83+
}
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()
7887
workflow.Spec.BootOptions.BootMode = tinkv1.BootMode("iso")
79-
workflow.Spec.BootOptions.ISOURL = scope.tinkerbellMachine.Spec.BootOptions.ISOURL
8088
}
8189
}
8290

0 commit comments

Comments
 (0)