Skip to content

Commit 078696a

Browse files
committed
introduce preprovisioningKernelParams to BMH
This commit: - Implements a new spec field of the BMH resource and implements related reconciliation logic in the bare metal host controller - Extends Ironic node update to servicing and preparing states too - Renames getInstanceUpdateOpts to getProvisioningInstanceUpdateOptsForNode to provide a more explicit name for the function and make it consistent with other UpdateOptsForNode type functions Notes: - The new spec field is optional and not using it should provide the same UX as older BMO versions - Kernel pre provisioning arguments can't be changed when a node transitions from inspected (available) state to provisioning state if Ironic is configured to fast-track deployments. Signed-off-by: Adam Rozman <[email protected]>
1 parent 3fdcd42 commit 078696a

File tree

21 files changed

+405
-291
lines changed

21 files changed

+405
-291
lines changed

apis/metal3.io/v1alpha1/baremetalhost_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,11 @@ type BareMetalHostSpec struct {
397397
// without hardware profiles.
398398
HardwareProfile string `json:"hardwareProfile,omitempty"`
399399

400+
// The value of the kernel commandline argument list that will be passed
401+
// to the pre provisioning agent's kernel during boot.
402+
// +optional
403+
PreprovisioningKernelParams string `json:"preprovisioningKernelParams,omitempty"`
404+
400405
// Provide guidance about how to choose the device for the image
401406
// being provisioned. The default is currently to use /dev/sda as
402407
// the root device.

internal/controller/metal3.io/baremetalhost_controller.go

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,15 @@ func (info *reconcileInfo) publishEvent(reason, message string) {
8383
info.events = append(info.events, info.host.NewEvent(reason, message))
8484
}
8585

86+
// return the PreprovisioningKernelParams from the reconciliation info.
87+
func retrievePreprovisioningKernelParamsSpec(info *reconcileInfo) string {
88+
preprovisioningKernelParams := ""
89+
if info.host.Spec.PreprovisioningKernelParams != "" {
90+
preprovisioningKernelParams = info.host.Spec.PreprovisioningKernelParams
91+
}
92+
return preprovisioningKernelParams
93+
}
94+
8695
// +kubebuilder:rbac:groups=metal3.io,resources=baremetalhosts,verbs=get;list;watch;create;update;patch;delete
8796
// +kubebuilder:rbac:groups=metal3.io,resources=baremetalhosts/status,verbs=get;update;patch
8897
// +kubebuilder:rbac:groups=metal3.io,resources=baremetalhosts/finalizers,verbs=update
@@ -839,15 +848,15 @@ func (r *BareMetalHostReconciler) registerHost(prov provisioner.Provisioner, inf
839848

840849
provResult, provID, err := prov.Register(
841850
provisioner.ManagementAccessData{
842-
BootMode: info.host.Status.Provisioning.BootMode,
843-
AutomatedCleaningMode: info.host.Spec.AutomatedCleaningMode,
844-
State: info.host.Status.Provisioning.State,
845-
CurrentImage: getCurrentImage(info.host),
846-
PreprovisioningImage: preprovImg,
847-
PreprovisioningNetworkData: preprovisioningNetworkData,
848-
HasCustomDeploy: hasCustomDeploy(info.host),
849-
DisablePowerOff: info.host.Spec.DisablePowerOff,
850-
CPUArchitecture: getHostArchitecture(info.host),
851+
BootMode: info.host.Status.Provisioning.BootMode,
852+
AutomatedCleaningMode: info.host.Spec.AutomatedCleaningMode,
853+
State: info.host.Status.Provisioning.State,
854+
CurrentImage: getCurrentImage(info.host),
855+
PreprovisioningImage: preprovImg,
856+
PreprovisioningNetworkData: preprovisioningNetworkData,
857+
PreprovisioningKernelParams: retrievePreprovisioningKernelParamsSpec(info),
858+
HasCustomDeploy: hasCustomDeploy(info.host),
859+
DisablePowerOff: info.host.Spec.DisablePowerOff,
851860
},
852861
credsChanged,
853862
info.host.Status.ErrorType == metal3api.RegistrationError)
@@ -987,7 +996,8 @@ func (r *BareMetalHostReconciler) actionInspecting(prov provisioner.Provisioner,
987996

988997
provResult, started, details, err := prov.InspectHardware(
989998
provisioner.InspectData{
990-
BootMode: info.host.Status.Provisioning.BootMode,
999+
BootMode: info.host.Status.Provisioning.BootMode,
1000+
PreprovisioningKernelParams: retrievePreprovisioningKernelParamsSpec(info),
9911001
},
9921002
info.host.Status.ErrorType == metal3api.InspectionError,
9931003
refresh,
@@ -1157,10 +1167,11 @@ func (r *BareMetalHostReconciler) actionPreparing(prov provisioner.Provisioner,
11571167
}
11581168

11591169
prepareData := provisioner.PrepareData{
1160-
TargetRAIDConfig: newStatus.Provisioning.RAID.DeepCopy(),
1161-
ActualRAIDConfig: info.host.Status.Provisioning.RAID.DeepCopy(),
1162-
RootDeviceHints: newStatus.Provisioning.RootDeviceHints.DeepCopy(),
1163-
FirmwareConfig: newStatus.Provisioning.Firmware.DeepCopy(),
1170+
TargetRAIDConfig: newStatus.Provisioning.RAID.DeepCopy(),
1171+
ActualRAIDConfig: info.host.Status.Provisioning.RAID.DeepCopy(),
1172+
RootDeviceHints: newStatus.Provisioning.RootDeviceHints.DeepCopy(),
1173+
FirmwareConfig: newStatus.Provisioning.Firmware.DeepCopy(),
1174+
PreprovisioningKernelParams: retrievePreprovisioningKernelParamsSpec(info),
11641175
}
11651176
// When manual cleaning fails, we think that the existing RAID configuration
11661177
// is invalid and needs to be reconfigured.
@@ -1282,12 +1293,13 @@ func (r *BareMetalHostReconciler) actionProvisioning(prov provisioner.Provisione
12821293
}
12831294

12841295
provResult, err := prov.Provision(provisioner.ProvisionData{
1285-
Image: image,
1286-
CustomDeploy: info.host.Spec.CustomDeploy.DeepCopy(),
1287-
HostConfig: hostConf,
1288-
BootMode: info.host.Status.Provisioning.BootMode,
1289-
HardwareProfile: hwProf,
1290-
RootDeviceHints: info.host.Status.Provisioning.RootDeviceHints.DeepCopy(),
1296+
Image: image,
1297+
CustomDeploy: info.host.Spec.CustomDeploy.DeepCopy(),
1298+
HostConfig: hostConf,
1299+
BootMode: info.host.Status.Provisioning.BootMode,
1300+
HardwareProfile: hwProf,
1301+
RootDeviceHints: info.host.Status.Provisioning.RootDeviceHints.DeepCopy(),
1302+
PreprovisioningKernelParams: retrievePreprovisioningKernelParamsSpec(info),
12911303
}, forceReboot)
12921304
if err != nil {
12931305
return actionError{fmt.Errorf("failed to provision: %w", err)}
@@ -1403,6 +1415,7 @@ func (r *BareMetalHostReconciler) actionDeprovisioning(prov provisioner.Provisio
14031415

14041416
func (r *BareMetalHostReconciler) doServiceIfNeeded(prov provisioner.Provisioner, info *reconcileInfo, hup *metal3api.HostUpdatePolicy) (result actionResult) {
14051417
servicingData := provisioner.ServicingData{}
1418+
servicingData.PreprovisioningKernelParams = retrievePreprovisioningKernelParamsSpec(info)
14061419

14071420
// (NOTE)janders: since Servicing is an opt-in feature that requires HostUpdatePolicy to be created and set to onReboot
14081421
// set below booleans to false by default and change to true based on policy settings

pkg/hardwareutils/bmc/access.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ type AccessDetails interface {
6868
// pre-populated with the access information, and the caller is
6969
// expected to add any other information that might be needed
7070
// (such as the kernel and ramdisk locations).
71-
DriverInfo(bmcCreds Credentials) map[string]interface{}
71+
DriverInfo(bmcCreds Credentials, preProvKernParams string) map[string]interface{}
7272

7373
BIOSInterface() string
7474

0 commit comments

Comments
 (0)