Skip to content

Commit 5a4095b

Browse files
committed
Add BMCSettingsApplyResultEntry type to BMCSettings status for ETag-based drift detection
Add the BMCSettingsApplyResultEntry struct to api/v1alpha1/bmcsettings_types.go and the AppliedETags field to BMCSettingsStatus: type BMCSettingsApplyResultEntry struct { URI string `json:"uri,omitempty"` ETag string `json:"etag,omitempty"` ValueHash string `json:"valueHash,omitempty"` } AppliedETags map[string]BMCSettingsApplyResultEntry `json:"appliedETags,omitempty"` - URI: the Redfish resource URI from the apply response (Location header for POST-created resources; request URI for PATCH) - ETag: drift-detection token after the last successful apply — either a real ETag returned by the BMC (e.g. W/"20B77DA6") or a SHA-256 hash of the GET response prefixed with "hash:sha256:" for BMCs that do not return ETag headers - ValueHash: SHA-256 of the effective (resolved) value at apply time, used to detect desired-state changes from ConfigMap/Secret rotation without relying on metadata.generation The type is named BMCSettingsApplyResultEntry (rather than ApplyResultEntry) to follow the existing sub-type naming convention (BMCSettingsSpec, BMCSettingsStatus, BMCSettingsSetStatus, etc.) and to scope it clearly to the BMCSettings resource. Regenerate CRD manifests, Helm chart, API docs, and deepcopy/applyconfiguration code via `make manifests generate helm docs`. No controller logic changes in this commit. Fixes #915 Part of #858 Signed-off-by: Andrew Dodds <andrew.dodds@sap.com>
1 parent e0b34f0 commit 5a4095b

9 files changed

Lines changed: 208 additions & 0 deletions

File tree

api/v1alpha1/applyconfiguration/api/v1alpha1/bmcsettingsapplyresultentry.go

Lines changed: 53 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha1/applyconfiguration/api/v1alpha1/bmcsettingsstatus.go

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha1/applyconfiguration/internal/internal.go

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha1/applyconfiguration/utils.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha1/bmcsettings_types.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,37 @@ type BMCSettingsStatus struct {
174174
// +optional
175175
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
176176

177+
// AppliedETags stores the URI, ETag, and value hash from the last successful apply for each settings key.
178+
// Used for ETag-based drift detection during verification.
179+
// +optional
180+
AppliedETags map[string]BMCSettingsApplyResultEntry `json:"appliedETags,omitempty"`
181+
177182
// Conditions represents the latest available observations of the BMC Settings Resource state.
178183
// +patchStrategy=merge
179184
// +patchMergeKey=type
180185
// +optional
181186
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
182187
}
183188

189+
// BMCSettingsApplyResultEntry holds the URI, ETag, and value hash from the last successful apply of a single settings key.
190+
type BMCSettingsApplyResultEntry struct {
191+
// URI is the Redfish resource URI from the apply response.
192+
// +optional
193+
URI string `json:"uri,omitempty"`
194+
195+
// ETag is the drift-detection token captured after the last successful apply.
196+
// Either a real ETag returned by the BMC (e.g. W/"20B77DA6") or a SHA-256
197+
// hash of the GET response prefixed with "hash:sha256:" for BMCs that do
198+
// not return ETag headers.
199+
// +optional
200+
ETag string `json:"etag,omitempty"`
201+
202+
// ValueHash is the SHA-256 hash of the effective (resolved) value at apply time.
203+
// Used to detect desired-state changes from ConfigMap/Secret rotation.
204+
// +optional
205+
ValueHash string `json:"valueHash,omitempty"`
206+
}
207+
184208
// +kubebuilder:object:root=true
185209
// +kubebuilder:subresource:status
186210
// +kubebuilder:resource:scope=Cluster

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,33 @@ spec:
257257
status:
258258
description: BMCSettingsStatus defines the observed state of BMCSettings.
259259
properties:
260+
appliedETags:
261+
additionalProperties:
262+
description: BMCSettingsApplyResultEntry holds the URI, ETag, and
263+
value hash from the last successful apply of a single settings
264+
key.
265+
properties:
266+
etag:
267+
description: |-
268+
ETag is the drift-detection token captured after the last successful apply.
269+
Either a real ETag returned by the BMC (e.g. W/"20B77DA6") or a SHA-256
270+
hash of the GET response prefixed with "hash:sha256:" for BMCs that do
271+
not return ETag headers.
272+
type: string
273+
uri:
274+
description: URI is the Redfish resource URI from the apply
275+
response.
276+
type: string
277+
valueHash:
278+
description: |-
279+
ValueHash is the SHA-256 hash of the effective (resolved) value at apply time.
280+
Used to detect desired-state changes from ConfigMap/Secret rotation.
281+
type: string
282+
type: object
283+
description: |-
284+
AppliedETags stores the URI, ETag, and value hash from the last successful apply for each settings key.
285+
Used for ETag-based drift detection during verification.
286+
type: object
260287
conditions:
261288
description: Conditions represents the latest available observations
262289
of the BMC Settings Resource state.

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,33 @@ spec:
263263
status:
264264
description: BMCSettingsStatus defines the observed state of BMCSettings.
265265
properties:
266+
appliedETags:
267+
additionalProperties:
268+
description: BMCSettingsApplyResultEntry holds the URI, ETag, and
269+
value hash from the last successful apply of a single settings
270+
key.
271+
properties:
272+
etag:
273+
description: |-
274+
ETag is the drift-detection token captured after the last successful apply.
275+
Either a real ETag returned by the BMC (e.g. W/"20B77DA6") or a SHA-256
276+
hash of the GET response prefixed with "hash:sha256:" for BMCs that do
277+
not return ETag headers.
278+
type: string
279+
uri:
280+
description: URI is the Redfish resource URI from the apply
281+
response.
282+
type: string
283+
valueHash:
284+
description: |-
285+
ValueHash is the SHA-256 hash of the effective (resolved) value at apply time.
286+
Used to detect desired-state changes from ConfigMap/Secret rotation.
287+
type: string
288+
type: object
289+
description: |-
290+
AppliedETags stores the URI, ETag, and value hash from the last successful apply for each settings key.
291+
Used for ETag-based drift detection during verification.
292+
type: object
266293
conditions:
267294
description: Conditions represents the latest available observations
268295
of the BMC Settings Resource state.

docs/api-reference/api.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,24 @@ BMCSettings is the Schema for the BMCSettings API.
483483
| `status` _[BMCSettingsStatus](#bmcsettingsstatus)_ | | | |
484484

485485

486+
#### BMCSettingsApplyResultEntry
487+
488+
489+
490+
BMCSettingsApplyResultEntry holds the URI, ETag, and value hash from the last successful apply of a single settings key.
491+
492+
493+
494+
_Appears in:_
495+
- [BMCSettingsStatus](#bmcsettingsstatus)
496+
497+
| Field | Description | Default | Validation |
498+
| --- | --- | --- | --- |
499+
| `uri` _string_ | URI is the Redfish resource URI from the apply response. | | |
500+
| `etag` _string_ | ETag is the drift-detection token captured after the last successful apply.<br />Either a real ETag returned by the BMC (e.g. W/"20B77DA6") or a SHA-256<br />hash of the GET response prefixed with "hash:sha256:" for BMCs that do<br />not return ETag headers. | | |
501+
| `valueHash` _string_ | ValueHash is the SHA-256 hash of the effective (resolved) value at apply time.<br />Used to detect desired-state changes from ConfigMap/Secret rotation. | | |
502+
503+
486504
#### BMCSettingsSet
487505

488506

@@ -597,6 +615,7 @@ _Appears in:_
597615
| `state` _[BMCSettingsState](#bmcsettingsstate)_ | State represents the current state of the BMC configuration task. | | |
598616
| `failedAttempts` _integer_ | FailedAttempts is the number of automatic retry attempts made after failure. | | |
599617
| `observedGeneration` _integer_ | ObservedGeneration is the most recent generation observed by the controller. | | |
618+
| `appliedETags` _object (keys:string, values:[BMCSettingsApplyResultEntry](#bmcsettingsapplyresultentry))_ | AppliedETags stores the URI, ETag, and value hash from the last successful apply for each settings key.<br />Used for ETag-based drift detection during verification. | | |
600619
| `conditions` _[Condition](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.36/#condition-v1-meta) array_ | Conditions represents the latest available observations of the BMC Settings Resource state. | | |
601620

602621

0 commit comments

Comments
 (0)