Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions apis/metal3.io/v1alpha1/baremetalhost_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,11 @@ type BareMetalHostSpec struct {
// without hardware profiles.
HardwareProfile string `json:"hardwareProfile,omitempty"`

// The value of the kernel commandline argument list that will be passed
// to the pre provisioning agent's kernel during boot.
// +optional
PreprovisioningExtraKernelParams string `json:"preprovisioningExtraKernelParams,omitempty"`

// Provide guidance about how to choose the device for the image
// being provisioned. The default is currently to use /dev/sda as
// the root device.
Expand Down
5 changes: 5 additions & 0 deletions config/base/crds/bases/metal3.io_baremetalhosts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,11 @@ spec:
state (e.g. provisioned), its power state will be forced to match
this value.
type: boolean
preprovisioningExtraKernelParams:
description: |-
The value of the kernel commandline argument list that will be passed
to the pre provisioning agent's kernel during boot.
type: string
preprovisioningNetworkDataName:
description: |-
PreprovisioningNetworkDataName is the name of the Secret in the
Expand Down
5 changes: 5 additions & 0 deletions config/render/capm3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,11 @@ spec:
state (e.g. provisioned), its power state will be forced to match
this value.
type: boolean
preprovisioningExtraKernelParams:
description: |-
The value of the kernel commandline argument list that will be passed
to the pre provisioning agent's kernel during boot.
type: string
preprovisioningNetworkDataName:
description: |-
PreprovisioningNetworkDataName is the name of the Secret in the
Expand Down
77 changes: 56 additions & 21 deletions internal/controller/metal3.io/baremetalhost_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,33 @@ func (info *reconcileInfo) publishEvent(reason, message string) {
info.events = append(info.events, info.host.NewEvent(reason, message))
}

// return the PreprovisioningExtraKernelParams from the reconciliation info.
func (r *BareMetalHostReconciler) retrievePreprovisioningExtraKernelParamsSpec(info *reconcileInfo, prov provisioner.Provisioner) string {
if info == nil || info.host == nil {
return ""
}
kernelExtraPreprovParams := info.host.Spec.PreprovisioningExtraKernelParams
preprovImgFormats, err := prov.PreprovisioningImageFormats()
if err != nil {
return kernelExtraPreprovParams
}
preprovImg, err := r.getPreprovImage(info, preprovImgFormats)
if err != nil {
return kernelExtraPreprovParams
}
// Make sure kernel extra params coming from dynamically generater preprov
// Image are also represented in every life cycle operation
if preprovImg != nil {
trimmedParams := strings.TrimSpace(kernelExtraPreprovParams)
if trimmedParams == "" {
kernelExtraPreprovParams = preprovImg.GeneratedImage.ExtraKernelParams
} else {
kernelExtraPreprovParams += " " + preprovImg.GeneratedImage.ExtraKernelParams
}
}
return kernelExtraPreprovParams
}

// +kubebuilder:rbac:groups=metal3.io,resources=baremetalhosts,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=metal3.io,resources=baremetalhosts/status,verbs=get;update;patch
// +kubebuilder:rbac:groups=metal3.io,resources=baremetalhosts/finalizers,verbs=update
Expand Down Expand Up @@ -839,15 +866,16 @@ func (r *BareMetalHostReconciler) registerHost(prov provisioner.Provisioner, inf

provResult, provID, err := prov.Register(
provisioner.ManagementAccessData{
BootMode: info.host.Status.Provisioning.BootMode,
AutomatedCleaningMode: info.host.Spec.AutomatedCleaningMode,
State: info.host.Status.Provisioning.State,
CurrentImage: getCurrentImage(info.host),
PreprovisioningImage: preprovImg,
PreprovisioningNetworkData: preprovisioningNetworkData,
HasCustomDeploy: hasCustomDeploy(info.host),
DisablePowerOff: info.host.Spec.DisablePowerOff,
CPUArchitecture: getHostArchitecture(info.host),
BootMode: info.host.Status.Provisioning.BootMode,
AutomatedCleaningMode: info.host.Spec.AutomatedCleaningMode,
State: info.host.Status.Provisioning.State,
CurrentImage: getCurrentImage(info.host),
PreprovisioningImage: preprovImg,
PreprovisioningNetworkData: preprovisioningNetworkData,
PreprovisioningExtraKernelParams: r.retrievePreprovisioningExtraKernelParamsSpec(info, prov),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is actually the only function that we need to pass PreprovisioningExtraKernelParams to (see other comments), so once the others are removed we should pass preprovImg as a param here instead of calling getPreprovImage() a second time.

HasCustomDeploy: hasCustomDeploy(info.host),
DisablePowerOff: info.host.Spec.DisablePowerOff,
CPUArchitecture: getHostArchitecture(info.host),
},
credsChanged,
info.host.Status.ErrorType == metal3api.RegistrationError)
Expand Down Expand Up @@ -987,7 +1015,8 @@ func (r *BareMetalHostReconciler) actionInspecting(prov provisioner.Provisioner,

provResult, started, details, err := prov.InspectHardware(
provisioner.InspectData{
BootMode: info.host.Status.Provisioning.BootMode,
BootMode: info.host.Status.Provisioning.BootMode,
PreprovisioningExtraKernelParams: r.retrievePreprovisioningExtraKernelParamsSpec(info, prov),
},
info.host.Status.ErrorType == metal3api.InspectionError,
refresh,
Expand Down Expand Up @@ -1157,10 +1186,11 @@ func (r *BareMetalHostReconciler) actionPreparing(prov provisioner.Provisioner,
}

prepareData := provisioner.PrepareData{
TargetRAIDConfig: newStatus.Provisioning.RAID.DeepCopy(),
ActualRAIDConfig: info.host.Status.Provisioning.RAID.DeepCopy(),
RootDeviceHints: newStatus.Provisioning.RootDeviceHints.DeepCopy(),
FirmwareConfig: newStatus.Provisioning.Firmware.DeepCopy(),
TargetRAIDConfig: newStatus.Provisioning.RAID.DeepCopy(),
ActualRAIDConfig: info.host.Status.Provisioning.RAID.DeepCopy(),
RootDeviceHints: newStatus.Provisioning.RootDeviceHints.DeepCopy(),
FirmwareConfig: newStatus.Provisioning.Firmware.DeepCopy(),
PreprovisioningExtraKernelParams: r.retrievePreprovisioningExtraKernelParamsSpec(info, prov),
}
// When manual cleaning fails, we think that the existing RAID configuration
// is invalid and needs to be reconfigured.
Expand Down Expand Up @@ -1282,12 +1312,13 @@ func (r *BareMetalHostReconciler) actionProvisioning(prov provisioner.Provisione
}

provResult, err := prov.Provision(provisioner.ProvisionData{
Image: image,
CustomDeploy: info.host.Spec.CustomDeploy.DeepCopy(),
HostConfig: hostConf,
BootMode: info.host.Status.Provisioning.BootMode,
HardwareProfile: hwProf,
RootDeviceHints: info.host.Status.Provisioning.RootDeviceHints.DeepCopy(),
Image: image,
CustomDeploy: info.host.Spec.CustomDeploy.DeepCopy(),
HostConfig: hostConf,
BootMode: info.host.Status.Provisioning.BootMode,
HardwareProfile: hwProf,
RootDeviceHints: info.host.Status.Provisioning.RootDeviceHints.DeepCopy(),
PreprovisioningExtraKernelParams: r.retrievePreprovisioningExtraKernelParamsSpec(info, prov),
}, forceReboot)
if err != nil {
return actionError{fmt.Errorf("failed to provision: %w", err)}
Expand Down Expand Up @@ -1366,9 +1397,12 @@ func (r *BareMetalHostReconciler) actionDeprovisioning(prov provisioner.Provisio
}
}

DeprovisionData := provisioner.DeprovisionData{
PreprovisioningExtraKernelParams: r.retrievePreprovisioningExtraKernelParamsSpec(info, prov),
}
info.log.Info("deprovisioning")

provResult, err := prov.Deprovision(info.host.Status.ErrorType == metal3api.ProvisioningError)
provResult, err := prov.Deprovision(DeprovisionData, info.host.Status.ErrorType == metal3api.ProvisioningError)
if err != nil {
return actionError{fmt.Errorf("failed to deprovision: %w", err)}
}
Expand Down Expand Up @@ -1403,6 +1437,7 @@ func (r *BareMetalHostReconciler) actionDeprovisioning(prov provisioner.Provisio

func (r *BareMetalHostReconciler) doServiceIfNeeded(prov provisioner.Provisioner, info *reconcileInfo, hup *metal3api.HostUpdatePolicy) (result actionResult) {
servicingData := provisioner.ServicingData{}
servicingData.PreprovisioningExtraKernelParams = r.retrievePreprovisioningExtraKernelParamsSpec(info, prov)

// (NOTE)janders: since Servicing is an opt-in feature that requires HostUpdatePolicy to be created and set to onReboot
// set below booleans to false by default and change to true based on policy settings
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/metal3.io/host_state_machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1374,7 +1374,7 @@ func (m *mockProvisioner) Provision(_ provisioner.ProvisionData, _ bool) (result
return m.getNextResultByMethod("Provision"), err
}

func (m *mockProvisioner) Deprovision(_ bool) (result provisioner.Result, err error) {
func (m *mockProvisioner) Deprovision(_ provisioner.DeprovisionData, _ bool) (result provisioner.Result, err error) {
return m.getNextResultByMethod("Deprovision"), err
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/hardwareutils/bmc/access.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ type AccessDetails interface {
// pre-populated with the access information, and the caller is
// expected to add any other information that might be needed
// (such as the kernel and ramdisk locations).
DriverInfo(bmcCreds Credentials) map[string]interface{}
DriverInfo(bmcCreds Credentials, preProvExtraKernParams string) map[string]interface{}

BIOSInterface() string

Expand Down
Loading