Skip to content

Commit 4516861

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 <adam.rozman@est.tech>
1 parent 3fdcd42 commit 4516861

23 files changed

Lines changed: 419 additions & 295 deletions

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+
PreprovisioningExtraKernelParams string `json:"preprovisioningExtraKernelParams,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.

config/base/crds/bases/metal3.io_baremetalhosts.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,11 @@ spec:
326326
state (e.g. provisioned), its power state will be forced to match
327327
this value.
328328
type: boolean
329+
preprovisioningExtraKernelParams:
330+
description: |-
331+
The value of the kernel commandline argument list that will be passed
332+
to the pre provisioning agent's kernel during boot.
333+
type: string
329334
preprovisioningNetworkDataName:
330335
description: |-
331336
PreprovisioningNetworkDataName is the name of the Secret in the

config/render/capm3.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,11 @@ spec:
326326
state (e.g. provisioned), its power state will be forced to match
327327
this value.
328328
type: boolean
329+
preprovisioningExtraKernelParams:
330+
description: |-
331+
The value of the kernel commandline argument list that will be passed
332+
to the pre provisioning agent's kernel during boot.
333+
type: string
329334
preprovisioningNetworkDataName:
330335
description: |-
331336
PreprovisioningNetworkDataName is the name of the Secret in the

internal/controller/metal3.io/baremetalhost_controller.go

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

86+
// return the PreprovisioningExtraKernelParams from the reconciliation info.
87+
func retrievePreprovisioningExtraKernelParamsSpec(info *reconcileInfo) string {
88+
if info == nil || info.host == nil {
89+
return ""
90+
}
91+
return info.host.Spec.PreprovisioningExtraKernelParams
92+
}
93+
8694
// +kubebuilder:rbac:groups=metal3.io,resources=baremetalhosts,verbs=get;list;watch;create;update;patch;delete
8795
// +kubebuilder:rbac:groups=metal3.io,resources=baremetalhosts/status,verbs=get;update;patch
8896
// +kubebuilder:rbac:groups=metal3.io,resources=baremetalhosts/finalizers,verbs=update
@@ -839,15 +847,16 @@ func (r *BareMetalHostReconciler) registerHost(prov provisioner.Provisioner, inf
839847

840848
provResult, provID, err := prov.Register(
841849
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),
850+
BootMode: info.host.Status.Provisioning.BootMode,
851+
AutomatedCleaningMode: info.host.Spec.AutomatedCleaningMode,
852+
State: info.host.Status.Provisioning.State,
853+
CurrentImage: getCurrentImage(info.host),
854+
PreprovisioningImage: preprovImg,
855+
PreprovisioningNetworkData: preprovisioningNetworkData,
856+
PreprovisioningExtraKernelParams: retrievePreprovisioningExtraKernelParamsSpec(info),
857+
HasCustomDeploy: hasCustomDeploy(info.host),
858+
DisablePowerOff: info.host.Spec.DisablePowerOff,
859+
CPUArchitecture: getHostArchitecture(info.host),
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+
PreprovisioningExtraKernelParams: retrievePreprovisioningExtraKernelParamsSpec(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+
PreprovisioningExtraKernelParams: retrievePreprovisioningExtraKernelParamsSpec(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+
PreprovisioningExtraKernelParams: retrievePreprovisioningExtraKernelParamsSpec(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.PreprovisioningExtraKernelParams = retrievePreprovisioningExtraKernelParamsSpec(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, preProvExtraKernParams string) map[string]interface{}
7272

7373
BIOSInterface() string
7474

0 commit comments

Comments
 (0)