Skip to content

Commit

Permalink
Default hardware MAC in iso mount workflows (#435)
Browse files Browse the repository at this point in the history
## Description

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.

## Why is this needed
Improves UX

Fixes: #

## How Has This Been Tested?



Built a custom CAPT image, and verified that the macAddress was populated in the workflow object. 

## How are existing users impacted? What migration steps/scripts do we need?





## Checklist:

I have:

- [ ] updated the documentation and/or roadmap (if required)
- [ ] added unit or e2e tests
- [ ] provided instructions on how to upgrade
  • Loading branch information
mergify[bot] authored Jan 16, 2025
2 parents 97ed2ed + 4377a37 commit da7daea
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# Build the manager binary
ARG GOVER=1.23
FROM golang:${GOVER} as builder
FROM golang:${GOVER} AS builder

WORKDIR /workspace

Expand Down
11 changes: 6 additions & 5 deletions api/v1beta1/tinkerbellmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,17 @@ type TinkerbellMachineSpec struct {
// BootOptions are options that control the booting of Hardware.
type BootOptions struct {
// ISOURL is the URL of the ISO that will be one-time booted.
// 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 format of the ISOURL must be http://$IP:$Port/iso/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".
// The controller will append the MAC address of the hardware in the ISO URL
// right before the iso file name in the URL.
// MAC address is then used to retrieve hardware specific information such as
// IPAM info, custom kernel cmd line args and populate the worker ID for the tink worker/agent.
// For ex. the above format would be replaced to http://$IP:$Port/iso/<macAddress>/hook.iso
// +optional
// +kubebuilder:validation:Format=url
ISOURL string `json:"isoURL,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,17 @@ spec:
isoURL:
description: |-
ISOURL is the URL of the ISO that will be one-time booted.
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 format of the ISOURL must be http://$IP:$Port/iso/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".
The controller will append the MAC address of the hardware in the ISO URL
right before the iso file name in the URL.
MAC address is then used to retrieve hardware specific information such as
IPAM info, custom kernel cmd line args and populate the worker ID for the tink worker/agent.
For ex. the above format would be replaced to http://$IP:$Port/iso/<macAddress>/hook.iso
format: url
type: string
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,17 @@ spec:
isoURL:
description: |-
ISOURL is the URL of the ISO that will be one-time booted.
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 format of the ISOURL must be http://$IP:$Port/iso/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".
The controller will append the MAC address of the hardware in the ISO URL
right before the iso file name in the URL.
MAC address is then used to retrieve hardware specific information such as
IPAM info, custom kernel cmd line args and populate the worker ID for the tink worker/agent.
For ex. the above format would be replaced to http://$IP:$Port/iso/<macAddress>/hook.iso
format: url
type: string
type: object
Expand Down
5 changes: 4 additions & 1 deletion controller/machine/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"net/url"
"path"
"strings"

"github.com/tinkerbell/cluster-api-provider-tinkerbell/api/v1beta1"
Expand Down Expand Up @@ -82,7 +83,9 @@ func (scope *machineReconcileScope) createWorkflow(hw *tinkv1.Hardware) error {
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)
urlPath, file := path.Split(u.Path)
u.Path = path.Join(urlPath, strings.Replace(hw.Spec.Metadata.Instance.ID, ":", "-", 5), file)

workflow.Spec.BootOptions.ISOURL = u.String()
workflow.Spec.BootOptions.BootMode = tinkv1.BootMode("iso")
}
Expand Down

0 comments on commit da7daea

Please sign in to comment.