Skip to content
Draft
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
3 changes: 3 additions & 0 deletions api/v1alpha1/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ const (
OperationAnnotationForceUpdateOrDeleteInProgress = "ForceUpdateOrDeleteInProgress"
// OperationAnnotationForceUpdateInProgress allows update of a resource even if it is in progress.
OperationAnnotationForceUpdateInProgress = "ForceUpdateInProgress"

// SkipBootConfiguration skips the boot configuration if set to this value.
SkipBootConfiguration = "skip-boot-configuration-enforement"
// OperationAnnotationForceReset forces a reset before next operation
OperationAnnotationForceReset = "ForceReset"
)
1 change: 1 addition & 0 deletions api/v1alpha1/server_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ type ServerSpec struct {
MaintenanceBootConfigurationRef *v1.ObjectReference `json:"maintenanceBootConfigurationRef,omitempty"`

// BootOrder specifies the boot order of the server.
// Deprecated: currently not supported.
// +optional
BootOrder []BootOrder `json:"bootOrder,omitempty"`

Expand Down
62 changes: 62 additions & 0 deletions api/v1alpha1/servermaintenance_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,33 @@ type ServerBootConfigurationTemplate struct {
// +required
Name string `json:"name"`

// BootType specifies the type of boot configuration.
// It can be either "OneOff" or "Persistent". If not specified, it defaults to "Persistent".
// "Persistent" will set the configuration reboot the server before setting the server to the desired power state mentioned in spec.
//
// "OneOff" will set the configuration to boot once. next boot-up will boot into default boot order.
// if power state mentioned in spec is "PowerOn", server will be powered on and will boot into the configuration.
// if power state is "PowerOff", server will be powered off and will boot into the configuration on next power on.
//
// +kubebuilder:validation:Enum=OneOff;Persistent
// +optional
// +kubebuilder:default=Persistent
BootType BootType `json:"bootType,omitempty"`

// Parameters specify the parameters to be used for rendering the boot configuration.
// +required
Spec ServerBootConfigurationSpec `json:"spec"`
}

type BootType string

const (
// BootTypeOneOff indicates that the server should boot into this configuration one time.
BootTypeOneOff BootType = "OneOff"
// BootTypePersistent indicates that the server should boot into this configuration continuously.
BootTypePersistent BootType = "Persistent"
)

// ServerMaintenanceSpec defines the desired state of a ServerMaintenance
type ServerMaintenanceSpec struct {
// Policy specifies the maintenance policy to be enforced on the server.
Expand Down Expand Up @@ -61,8 +83,46 @@ const (
type ServerMaintenanceStatus struct {
// State specifies the current state of the server maintenance.
State ServerMaintenanceState `json:"state,omitempty"`

// BootOrderStatus specifies the boot order of the server before maintenance.
// is used to store the boot order of server before it is changed for maintenance.
// used only with BootType Persistent.
// +optional
BootOrderStatus *ServerMaintenanceBootOrder `json:"bootOrderStatus,omitempty"`
}

type ServerMaintenanceBootOrder struct {
// DefaultBootOrder specifies the default boot order of the server before maintenance.
// +optional
DefaultBootOrder []string `json:"defaultBootOrder,omitempty"`

State ServerMaintenanceBootOrderState `json:"state,omitempty"`
}

// ServerMaintenanceState specifies the current state of the server maintenance.
type ServerMaintenanceBootOrderState string

const (

// BootOrderConfigNoOp specifies that the server bootOrder is as expected.
BootOrderConfigNoOp ServerMaintenanceBootOrderState = "NoOp"

// BootOrderConfigInProgress specifies that the server bootOrder configuration is InProgress.
BootOrderConfigInProgress ServerMaintenanceBootOrderState = "InProgress"

// BootOrderConfigSuccess specifies that the server bootOrder configuration is Completed.
BootOrderConfigSuccess ServerMaintenanceBootOrderState = "Completed"

// BootOrderConfigSuccessRevertInProgress specifies that the server bootOrder revert to default is InProgress.
BootOrderConfigSuccessRevertInProgress ServerMaintenanceBootOrderState = "RevertInProgress"

// BootOrderConfigRevertSuccess specifies that the server bootOrder configuration is Completed.
BootOrderConfigRevertSuccess ServerMaintenanceBootOrderState = "RevertCompleted"

// BootOrderOneOffPxeBootSuccess specifies that the server bootOrder configuration is set to boot pxe once.
BootOrderOneOffPxeBootSuccess ServerMaintenanceBootOrderState = "PxeOneOffBootSuccess"
)

// ServerMaintenanceState specifies the current state of the server maintenance.
type ServerMaintenanceState string

Expand All @@ -71,6 +131,8 @@ const (
ServerMaintenanceStatePending ServerMaintenanceState = "Pending"
// ServerMaintenanceStateInMaintenance specifies that the server is in maintenance.
ServerMaintenanceStateInMaintenance ServerMaintenanceState = "InMaintenance"
// ServerMaintenanceStatePreparing specifies that the server is in maintenance.
ServerMaintenanceStatePreparing ServerMaintenanceState = "Preparing"
// ServerMaintenanceStateFailed specifies that the server maintenance has failed.
ServerMaintenanceStateFailed ServerMaintenanceState = "Failed"
)
Expand Down
27 changes: 26 additions & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion bmc/bmc.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ type BMC interface {
// GetBootOrder retrieves the boot order for the system.
GetBootOrder(ctx context.Context, systemURI string) ([]string, error)

// GetBootOptions retrieves the boot options for the system.
GetBootOptions(ctx context.Context, systemURI string) ([]*redfish.BootOption, error)

// GetBiosAttributeValues retrieves BIOS attribute values for the system.
GetBiosAttributeValues(ctx context.Context, systemURI string, attributes []string) (redfish.SettingsAttributes, error)

Expand Down Expand Up @@ -99,7 +102,7 @@ type BMC interface {
GetBMCVersion(ctx context.Context, UUID string) (string, error)

// SetBootOrder sets the boot order for the system.
SetBootOrder(ctx context.Context, systemURI string, order []string) error
SetBootOrder(ctx context.Context, systemURI string, order redfish.Boot) error

// GetStorages retrieves storage information for the system.
GetStorages(ctx context.Context, systemURI string) ([]Storage, error)
Expand Down
35 changes: 26 additions & 9 deletions bmc/redfish.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,14 @@ func (r *RedfishBMC) GetBootOrder(ctx context.Context, systemURI string) ([]stri
return system.Boot.BootOrder, nil
}

func (r *RedfishBMC) GetBootOptions(ctx context.Context, systemURI string) ([]*redfish.BootOption, error) {
system, err := r.getSystemFromUri(ctx, systemURI)
if err != nil {
return nil, err
}
return system.BootOptions()
}

func (r *RedfishBMC) GetBiosVersion(ctx context.Context, systemURI string) (string, error) {
system, err := r.getSystemFromUri(ctx, systemURI)
if err != nil {
Expand Down Expand Up @@ -474,21 +482,30 @@ func (r *RedfishBMC) SetBMCAttributesImmediately(ctx context.Context, bmcUUID st
}

// SetBootOrder sets bios boot order
func (r *RedfishBMC) SetBootOrder(ctx context.Context, systemURI string, bootOrder []string) error {
func (r *RedfishBMC) SetBootOrder(ctx context.Context, systemURI string, bootOrder redfish.Boot) error {
system, err := r.getSystemFromUri(ctx, systemURI)
if err != nil {
return err
}
return system.SetBoot(
redfish.Boot{
BootSourceOverrideEnabled: redfish.ContinuousBootSourceOverrideEnabled,
BootSourceOverrideTarget: redfish.NoneBootSourceOverrideTarget,
BootOrder: bootOrder,
},
)
var tSystem struct {
Settings common.Settings `json:"@Redfish.Settings"`
}
// Unfortunately, some vendors (like Dell) support setting through different url.
// Hence we need to set it through this url.
err = json.Unmarshal(system.RawData, &tSystem)
if err != nil {
return err
}
if tSystem.Settings.SettingsObject.String() == "" {
return system.SetBoot(bootOrder)
}
return system.SetBoot(bootOrder)
}

func (r *RedfishBMC) getFilteredBiosRegistryAttributes(readOnly bool, immutable bool) (map[string]RegistryEntryAttributes, error) {
func (r *RedfishBMC) getFilteredBiosRegistryAttributes(
readOnly bool,
immutable bool,
) (map[string]RegistryEntryAttributes, error) {
registries, err := r.client.Service.Registries()
if err != nil {
return nil, err
Expand Down
9 changes: 9 additions & 0 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,15 @@ func main() { // nolint: gocyclo
if err = (&controller.ServerMaintenanceReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
BMCOptions: bmc.Options{
BasicAuth: true,
PowerPollingInterval: powerPollingInterval,
PowerPollingTimeout: powerPollingTimeout,
ResourcePollingInterval: resourcePollingInterval,
ResourcePollingTimeout: resourcePollingTimeout,
},
Insecure: insecure,
ResyncInterval: serverResyncInterval,
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "ServerMaintenance")
os.Exit(1)
Expand Down
31 changes: 31 additions & 0 deletions config/crd/bases/metal.ironcore.dev_servermaintenances.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,20 @@ spec:
description: ServerBootConfigurationTemplate specifies the boot configuration
to be applied to the server during maintenance.
properties:
bootType:
default: Persistent
description: |-
BootType specifies the type of boot configuration.
It can be either "OneOff" or "Persistent". If not specified, it defaults to "Persistent".
"Persistent" will set the configuration reboot the server before setting the server to the desired power state mentioned in spec.

"OneOff" will set the configuration to boot once. next boot-up will boot into default boot order.
if power state mentioned in spec is "PowerOn", server will be powered on and will boot into the configuration.
if power state is "PowerOff", server will be powered off and will boot into the configuration on next power on.
enum:
- OneOff
- Persistent
type: string
name:
description: Name specifies the name of the boot configuration.
type: string
Expand Down Expand Up @@ -141,6 +155,23 @@ spec:
status:
description: ServerMaintenanceStatus defines the observed state of a ServerMaintenance
properties:
bootOrderStatus:
description: |-
BootOrderStatus specifies the boot order of the server before maintenance.
is used to store the boot order of server before it is changed for maintenance.
used only with BootType Persistent.
properties:
defaultBootOrder:
description: DefaultBootOrder specifies the default boot order
of the server before maintenance.
items:
type: string
type: array
state:
description: ServerMaintenanceState specifies the current state
of the server maintenance.
type: string
type: object
state:
description: State specifies the current state of the server maintenance.
type: string
Expand Down
4 changes: 3 additions & 1 deletion config/crd/bases/metal.ironcore.dev_servers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@ spec:
type: object
x-kubernetes-map-type: atomic
bootOrder:
description: BootOrder specifies the boot order of the server.
description: |-
BootOrder specifies the boot order of the server.
Deprecated: currently not supported.
items:
description: BootOrder represents the boot order of the server.
properties:
Expand Down
14 changes: 13 additions & 1 deletion config/samples/metal_v1alpha1_servermaintenance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,17 @@ metadata:
app.kubernetes.io/name: metal-operator
app.kubernetes.io/managed-by: kustomize
name: servermaintenance-sample
namespace: default
spec:
# TODO(user): Add fields here
serverRef:
name: node005-ap046-system-0
policy: metalv1alpha1.ServerMaintenancePolicyEnforced
serverPower: metalv1alpha1.PowerOn
serverBootConfigurationTemplate:
name: "test-boot"
spec:
ignitionSecretRef:
name: ignition-secret
serverRef:
name: server-system-0
image: "ghcr.io//foo/linux:C.X"
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,20 @@ spec:
description: ServerBootConfigurationTemplate specifies the boot configuration
to be applied to the server during maintenance.
properties:
bootType:
default: Persistent
description: |-
BootType specifies the type of boot configuration.
It can be either "OneOff" or "Persistent". If not specified, it defaults to "Persistent".
"Persistent" will set the configuration reboot the server before setting the server to the desired power state mentioned in spec.

"OneOff" will set the configuration to boot once. next boot-up will boot into default boot order.
if power state mentioned in spec is "PowerOn", server will be powered on and will boot into the configuration.
if power state is "PowerOff", server will be powered off and will boot into the configuration on next power on.
enum:
- OneOff
- Persistent
type: string
name:
description: Name specifies the name of the boot configuration.
type: string
Expand Down Expand Up @@ -147,6 +161,23 @@ spec:
status:
description: ServerMaintenanceStatus defines the observed state of a ServerMaintenance
properties:
bootOrderStatus:
description: |-
BootOrderStatus specifies the boot order of the server before maintenance.
is used to store the boot order of server before it is changed for maintenance.
used only with BootType Persistent.
properties:
defaultBootOrder:
description: DefaultBootOrder specifies the default boot order
of the server before maintenance.
items:
type: string
type: array
state:
description: ServerMaintenanceState specifies the current state
of the server maintenance.
type: string
type: object
state:
description: State specifies the current state of the server maintenance.
type: string
Expand Down
4 changes: 3 additions & 1 deletion dist/chart/templates/crd/metal.ironcore.dev_servers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ spec:
type: object
x-kubernetes-map-type: atomic
bootOrder:
description: BootOrder specifies the boot order of the server.
description: |-
BootOrder specifies the boot order of the server.
Deprecated: currently not supported.
items:
description: BootOrder represents the boot order of the server.
properties:
Expand Down
Loading
Loading