Skip to content

Commit c5b0278

Browse files
improve documentation for biosSettings
1 parent 862ba75 commit c5b0278

File tree

8 files changed

+110
-99
lines changed

8 files changed

+110
-99
lines changed

api/v1alpha1/biossettings_types.go

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,28 @@ import (
88
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
99
)
1010

11-
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
12-
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
13-
1411
// BIOSSettingsSpec defines the desired state of BIOSSettings.
1512
type BIOSSettingsSpec struct {
16-
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
17-
// Important: Run "make" to regenerate code after modifying this file
18-
19-
// BIOSSettings specifies the BIOS settings for the selected serverRef or serverSelector.
20-
BIOSSettings Settings `json:"biosSettings,omitempty"`
13+
// BIOSSettingsSpec specifies the BIOS settings for the selected serverRef.
14+
BIOSSettingsSpec Settings `json:"biosSettingsSpec,omitempty"`
2115

2216
// ServerRef is a reference to a specific server to apply bios setting on.
2317
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="serverRef is immutable"
2418
ServerRef *corev1.LocalObjectReference `json:"serverRef,omitempty"`
2519

2620
// ServerMaintenancePolicy is maintenance policy to be enforced on the server.
27-
ServerMaintenancePolicy ServerMaintenancePolicy `json:"serverMaintenancePolicy,omitempty"`
21+
ServerMaintenancePolicyType ServerMaintenancePolicy `json:"serverMaintenancePolicyType,omitempty"`
2822

2923
// ServerMaintenanceRef is a reference to a ServerMaintenance object that BiosSetting has requested for the referred server.
3024
ServerMaintenanceRef *corev1.ObjectReference `json:"serverMaintenanceRef,omitempty"`
3125
}
3226

3327
type Settings struct {
34-
// Version contains BIOS version this settings applies to
28+
// Version contains software (eg: BIOS, BMC) version this settings applies to
3529
// +required
3630
Version string `json:"version"`
3731

38-
// SettingsMap contains bios settings as map
32+
// SettingsMap contains software (eg: BIOS, BMC) settings as map
3933
// +optional
4034
SettingsMap map[string]string `json:"settings,omitempty"`
4135
}
@@ -44,13 +38,13 @@ type Settings struct {
4438
type BIOSSettingsState string
4539

4640
const (
47-
// BIOSSettingsStatePending specifies that the server bios is in setting update path.
41+
// BIOSSettingsStatePending specifies that the bios setting maintenance is waiting
4842
BIOSSettingsStatePending BIOSSettingsState = "Pending"
49-
// BIOSSettingsStateInProgress specifies that the server bios is in setting update path.
43+
// BIOSSettingsStateInProgress specifies that the BIOSSetting Controller is updating the settings
5044
BIOSSettingsStateInProgress BIOSSettingsState = "InProgress"
51-
// BIOSSettingsStateApplied specifies that the server bios maintenance has been completed.
45+
// BIOSSettingsStateApplied specifies that the bios setting maintenance has been completed.
5246
BIOSSettingsStateApplied BIOSSettingsState = "Applied"
53-
// BIOSSettingsStateFailed specifies that the server maintenance has failed.
47+
// BIOSSettingsStateFailed specifies that the bios setting maintenance has failed.
5448
BIOSSettingsStateFailed BIOSSettingsState = "Failed"
5549
)
5650

@@ -61,9 +55,9 @@ const (
6155
BIOSSettingUpdateWaitOnServerRebootPowerOff BIOSSettingUpdateState = "WaitOnServerRebootPowerOff"
6256
// BIOSSettingUpdateWaitOnServerRebootPowerOn specifies that the bios setting state is waiting on server to turn on during Reboot.
6357
BIOSSettingUpdateWaitOnServerRebootPowerOn BIOSSettingUpdateState = "WaitOnServerRebootPowerOn"
64-
// BIOSSettingUpdateStateIssue specifies that the bios new setting was posted to RedFish
58+
// BIOSSettingUpdateStateIssue specifies that the bios new setting was posted to server's RedFish API
6559
BIOSSettingUpdateStateIssue BIOSSettingUpdateState = "IssueSettingUpdate"
66-
// BIOSSettingUpdateStateVerification specifies that the bios setting has been completed.
60+
// BIOSSettingUpdateStateVerification specifies that the bios setting is beening verified.
6761
BIOSSettingUpdateStateVerification BIOSSettingUpdateState = "VerifySettingUpdate"
6862
)
6963

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/metal.ironcore.dev_biossettings.yaml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,23 +52,24 @@ spec:
5252
spec:
5353
description: BIOSSettingsSpec defines the desired state of BIOSSettings.
5454
properties:
55-
biosSettings:
56-
description: BIOSSettings specifies the BIOS settings for the selected
57-
serverRef or serverSelector.
55+
biosSettingsSpec:
56+
description: BIOSSettingsSpec specifies the BIOS settings for the
57+
selected serverRef.
5858
properties:
5959
settings:
6060
additionalProperties:
6161
type: string
62-
description: SettingsMap contains bios settings as map
62+
description: 'SettingsMap contains software (eg: BIOS, BMC) settings
63+
as map'
6364
type: object
6465
version:
65-
description: Version contains BIOS version this settings applies
66-
to
66+
description: 'Version contains software (eg: BIOS, BMC) version
67+
this settings applies to'
6768
type: string
6869
required:
6970
- version
7071
type: object
71-
serverMaintenancePolicy:
72+
serverMaintenancePolicyType:
7273
description: ServerMaintenancePolicy is maintenance policy to be enforced
7374
on the server.
7475
type: string

config/samples/metal_v1alpha1_biossettings.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ spec:
1212
version: 2.10.2
1313
settings:
1414
PxeDev1EnDis: Enabled
15-
ServerMaintenancePolicyTemplate: OwnerApproval
15+
serverMaintenancePolicyType: OwnerApproval

dist/chart/templates/crd/metal.ironcore.dev_biossettings.yaml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,23 +58,24 @@ spec:
5858
spec:
5959
description: BIOSSettingsSpec defines the desired state of BIOSSettings.
6060
properties:
61-
biosSettings:
62-
description: BIOSSettings specifies the BIOS settings for the selected
63-
serverRef or serverSelector.
61+
biosSettingsSpec:
62+
description: BIOSSettingsSpec specifies the BIOS settings for the
63+
selected serverRef.
6464
properties:
6565
settings:
6666
additionalProperties:
6767
type: string
68-
description: SettingsMap contains bios settings as map
68+
description: 'SettingsMap contains software (eg: BIOS, BMC) settings
69+
as map'
6970
type: object
7071
version:
71-
description: Version contains BIOS version this settings applies
72-
to
72+
description: 'Version contains software (eg: BIOS, BMC) version
73+
this settings applies to'
7374
type: string
7475
required:
7576
- version
7677
type: object
77-
serverMaintenancePolicy:
78+
serverMaintenancePolicyType:
7879
description: ServerMaintenancePolicy is maintenance policy to be enforced
7980
on the server.
8081
type: string

docs/api-reference/api.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ Resource Types:
2525
</tr>
2626
</thead>
2727
<tbody><tr><td><p>&#34;IssueSettingUpdate&#34;</p></td>
28-
<td><p>BIOSSettingUpdateStateIssue specifies that the bios new setting was posted to RedFish</p>
28+
<td><p>BIOSSettingUpdateStateIssue specifies that the bios new setting was posted to server&rsquo;s RedFish API</p>
2929
</td>
3030
</tr><tr><td><p>&#34;VerifySettingUpdate&#34;</p></td>
31-
<td><p>BIOSSettingUpdateStateVerification specifies that the bios setting has been completed.</p>
31+
<td><p>BIOSSettingUpdateStateVerification specifies that the bios setting is beening verified.</p>
3232
</td>
3333
</tr><tr><td><p>&#34;WaitOnServerRebootPowerOff&#34;</p></td>
3434
<td><p>BIOSSettingUpdateWaitOnServerRebootPowerOff specifies that the bios setting state is waiting on server to turn off during Reboot.</p>
@@ -80,15 +80,15 @@ BIOSSettingsSpec
8080
<table>
8181
<tr>
8282
<td>
83-
<code>biosSettings</code><br/>
83+
<code>biosSettingsSpec</code><br/>
8484
<em>
8585
<a href="#metal.ironcore.dev/v1alpha1.Settings">
8686
Settings
8787
</a>
8888
</em>
8989
</td>
9090
<td>
91-
<p>BIOSSettings specifies the BIOS settings for the selected serverRef or serverSelector.</p>
91+
<p>BIOSSettingsSpec specifies the BIOS settings for the selected serverRef.</p>
9292
</td>
9393
</tr>
9494
<tr>
@@ -106,7 +106,7 @@ Kubernetes core/v1.LocalObjectReference
106106
</tr>
107107
<tr>
108108
<td>
109-
<code>serverMaintenancePolicy</code><br/>
109+
<code>serverMaintenancePolicyType</code><br/>
110110
<em>
111111
<a href="#metal.ironcore.dev/v1alpha1.ServerMaintenancePolicy">
112112
ServerMaintenancePolicy
@@ -165,15 +165,15 @@ BIOSSettingsStatus
165165
<tbody>
166166
<tr>
167167
<td>
168-
<code>biosSettings</code><br/>
168+
<code>biosSettingsSpec</code><br/>
169169
<em>
170170
<a href="#metal.ironcore.dev/v1alpha1.Settings">
171171
Settings
172172
</a>
173173
</em>
174174
</td>
175175
<td>
176-
<p>BIOSSettings specifies the BIOS settings for the selected serverRef or serverSelector.</p>
176+
<p>BIOSSettingsSpec specifies the BIOS settings for the selected serverRef.</p>
177177
</td>
178178
</tr>
179179
<tr>
@@ -191,7 +191,7 @@ Kubernetes core/v1.LocalObjectReference
191191
</tr>
192192
<tr>
193193
<td>
194-
<code>serverMaintenancePolicy</code><br/>
194+
<code>serverMaintenancePolicyType</code><br/>
195195
<em>
196196
<a href="#metal.ironcore.dev/v1alpha1.ServerMaintenancePolicy">
197197
ServerMaintenancePolicy
@@ -233,16 +233,16 @@ Kubernetes core/v1.ObjectReference
233233
</tr>
234234
</thead>
235235
<tbody><tr><td><p>&#34;Applied&#34;</p></td>
236-
<td><p>BIOSSettingsStateApplied specifies that the server bios maintenance has been completed.</p>
236+
<td><p>BIOSSettingsStateApplied specifies that the bios setting maintenance has been completed.</p>
237237
</td>
238238
</tr><tr><td><p>&#34;Failed&#34;</p></td>
239-
<td><p>BIOSSettingsStateFailed specifies that the server maintenance has failed.</p>
239+
<td><p>BIOSSettingsStateFailed specifies that the bios setting maintenance has failed.</p>
240240
</td>
241241
</tr><tr><td><p>&#34;InProgress&#34;</p></td>
242-
<td><p>BIOSSettingsStateInProgress specifies that the server bios is in setting update path.</p>
242+
<td><p>BIOSSettingsStateInProgress specifies that the BIOSSetting Controller is updating the settings</p>
243243
</td>
244244
</tr><tr><td><p>&#34;Pending&#34;</p></td>
245-
<td><p>BIOSSettingsStatePending specifies that the server bios is in setting update path.</p>
245+
<td><p>BIOSSettingsStatePending specifies that the bios setting maintenance is waiting</p>
246246
</td>
247247
</tr></tbody>
248248
</table>
@@ -2880,7 +2880,7 @@ string
28802880
</em>
28812881
</td>
28822882
<td>
2883-
<p>Version contains BIOS version this settings applies to</p>
2883+
<p>Version contains software (eg: BIOS, BMC) version this settings applies to</p>
28842884
</td>
28852885
</tr>
28862886
<tr>
@@ -2892,7 +2892,7 @@ map[string]string
28922892
</td>
28932893
<td>
28942894
<em>(Optional)</em>
2895-
<p>SettingsMap contains bios settings as map</p>
2895+
<p>SettingsMap contains software (eg: BIOS, BMC) settings as map</p>
28962896
</td>
28972897
</tr>
28982898
</tbody>

internal/controller/biossettings_controller.go

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ func (r *BiosSettingsReconciler) reconcile(
211211
}
212212
// check if the current BIOS setting version is newer and update reference if it is newer
213213
// todo : handle version checks correctly
214-
if referredBIOSSetting.Spec.BIOSSettings.Version < biosSettings.Spec.BIOSSettings.Version {
214+
if referredBIOSSetting.Spec.BIOSSettingsSpec.Version < biosSettings.Spec.BIOSSettingsSpec.Version {
215215
log.V(1).Info("Updating BIOSSetting reference to the latest BIOS version")
216216
if err := r.patchBiosSettingsRefOnServer(ctx, log, server, &corev1.LocalObjectReference{Name: biosSettings.Name}); err != nil {
217217
return ctrl.Result{}, err
@@ -223,10 +223,10 @@ func (r *BiosSettingsReconciler) reconcile(
223223
return ctrl.Result{}, err
224224
}
225225

226-
return r.ensureServerMaintenanceStateTransition(ctx, log, biosSettings, server)
226+
return r.ensureBIOSSettingsStateTransition(ctx, log, biosSettings, server)
227227
}
228228

229-
func (r *BiosSettingsReconciler) ensureServerMaintenanceStateTransition(
229+
func (r *BiosSettingsReconciler) ensureBIOSSettingsStateTransition(
230230
ctx context.Context,
231231
log logr.Logger,
232232
biosSettings *metalv1alpha1.BIOSSettings,
@@ -275,8 +275,8 @@ func (r *BiosSettingsReconciler) handleSettingInProgressState(
275275
}
276276

277277
// todo:wait on the result from the resource which does upgrade to requeue.
278-
if currentBiosVersion != biosSettings.Spec.BIOSSettings.Version {
279-
log.V(1).Info("Pending BIOS version upgrade.", "current bios Version", currentBiosVersion, "required version", biosSettings.Spec.BIOSSettings.Version)
278+
if currentBiosVersion != biosSettings.Spec.BIOSSettingsSpec.Version {
279+
log.V(1).Info("Pending BIOS version upgrade.", "current bios Version", currentBiosVersion, "required version", biosSettings.Spec.BIOSSettingsSpec.Version)
280280
return ctrl.Result{}, nil
281281
}
282282

@@ -534,7 +534,7 @@ func (r *BiosSettingsReconciler) getBIOSVersionAndSettingDifference(
534534
}
535535
defer bmcClient.Logout()
536536

537-
keys := slices.Collect(maps.Keys(biosSettings.Spec.BIOSSettings.SettingsMap))
537+
keys := slices.Collect(maps.Keys(biosSettings.Spec.BIOSSettingsSpec.SettingsMap))
538538

539539
currentSettings, err := bmcClient.GetBiosAttributeValues(ctx, server.Spec.SystemUUID, keys)
540540
if err != nil {
@@ -544,7 +544,7 @@ func (r *BiosSettingsReconciler) getBIOSVersionAndSettingDifference(
544544

545545
diff = redfish.SettingsAttributes{}
546546
var errs []error
547-
for key, value := range biosSettings.Spec.BIOSSettings.SettingsMap {
547+
for key, value := range biosSettings.Spec.BIOSSettingsSpec.SettingsMap {
548548
res, ok := currentSettings[key]
549549
if ok {
550550
switch data := res.(type) {
@@ -645,7 +645,7 @@ func (r *BiosSettingsReconciler) requestMaintenanceOnServer(
645645
}}
646646

647647
opResult, err := controllerutil.CreateOrPatch(ctx, r.Client, serverMaintenance, func() error {
648-
serverMaintenance.Spec.Policy = biosSettings.Spec.ServerMaintenancePolicy
648+
serverMaintenance.Spec.Policy = biosSettings.Spec.ServerMaintenancePolicyType
649649
serverMaintenance.Spec.ServerPower = metalv1alpha1.PowerOn
650650
serverMaintenance.Spec.ServerRef = &corev1.LocalObjectReference{Name: server.Name}
651651
if serverMaintenance.Status.State != metalv1alpha1.ServerMaintenanceStateInMaintenance && serverMaintenance.Status.State != "" {
@@ -842,21 +842,32 @@ func (r *BiosSettingsReconciler) enqueueBiosSettingsByRefs(
842842
) []ctrl.Request {
843843
log := ctrl.LoggerFrom(ctx)
844844
host := obj.(*metalv1alpha1.Server)
845+
846+
// return early if hosts are not required states
847+
if host.Status.State == metalv1alpha1.ServerStateDiscovery ||
848+
host.Status.State == metalv1alpha1.ServerStateError ||
849+
host.Status.State == metalv1alpha1.ServerStateInitial {
850+
return nil
851+
}
852+
845853
BIOSSettingsList := &metalv1alpha1.BIOSSettingsList{}
846854
if err := r.List(ctx, BIOSSettingsList); err != nil {
847855
log.Error(err, "failed to list biosSettings")
848856
return nil
849857
}
850-
var req []ctrl.Request
851858

852859
for _, biosSettings := range BIOSSettingsList.Items {
853-
if biosSettings.Spec.ServerRef.Name == host.Name && biosSettings.Spec.ServerMaintenanceRef != nil {
854-
req = append(req, ctrl.Request{
855-
NamespacedName: types.NamespacedName{Namespace: biosSettings.Namespace, Name: biosSettings.Name},
856-
})
860+
if biosSettings.Spec.ServerRef.Name == host.Name {
861+
// states where we do not want to requeue for host changes
862+
if biosSettings.Spec.ServerMaintenanceRef == nil ||
863+
biosSettings.Status.State == metalv1alpha1.BIOSSettingsStateApplied ||
864+
biosSettings.Status.State == metalv1alpha1.BIOSSettingsStateFailed {
865+
return nil
866+
}
867+
return []ctrl.Request{{NamespacedName: types.NamespacedName{Namespace: biosSettings.Namespace, Name: biosSettings.Name}}}
857868
}
858869
}
859-
return req
870+
return nil
860871
}
861872

862873
// SetupWithManager sets up the controller with the Manager.

0 commit comments

Comments
 (0)