Skip to content

Commit 36fd51b

Browse files
committed
Review comments
1 parent 6f510fd commit 36fd51b

12 files changed

Lines changed: 70 additions & 13 deletions

api/v1alpha1/httpbootconfig_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ type HTTPBootConfigSpec struct {
2727
type HTTPBootConfigStatus struct {
2828
State HTTPBootConfigState `json:"state,omitempty"`
2929

30+
// ObservedGeneration is the generation of the HTTPBootConfig that was last reconciled by the controller.
31+
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
32+
3033
// Conditions represent the latest available observations of the IPXEBootConfig's state
3134
Conditions []metav1.Condition `json:"conditions,omitempty"`
3235
}

api/v1alpha1/ipxebootconfig_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ type IPXEBootConfigStatus struct {
5959
// Important: Run "make" to regenerate code after modifying this file
6060
State IPXEBootConfigState `json:"state,omitempty"`
6161

62+
// ObservedGeneration is the generation of the IPXEBootConfig that was last reconciled by the controller.
63+
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
64+
6265
// Conditions represent the latest available observations of the IPXEBootConfig's state
6366
Conditions []metav1.Condition `json:"conditions,omitempty"`
6467
}

config/crd/bases/boot.ironcore.dev_httpbootconfigs.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ spec:
136136
- type
137137
type: object
138138
type: array
139+
observedGeneration:
140+
description: ObservedGeneration is the generation of the HTTPBootConfig
141+
that was last reconciled by the controller.
142+
format: int64
143+
type: integer
139144
state:
140145
type: string
141146
type: object

config/crd/bases/boot.ironcore.dev_ipxebootconfigs.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,11 @@ spec:
165165
- type
166166
type: object
167167
type: array
168+
observedGeneration:
169+
description: ObservedGeneration is the generation of the IPXEBootConfig
170+
that was last reconciled by the controller.
171+
format: int64
172+
type: integer
168173
state:
169174
description: 'Important: Run "make" to regenerate code after modifying
170175
this file'

dist/chart/templates/crd/boot.ironcore.dev_httpbootconfigs.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ spec:
142142
- type
143143
type: object
144144
type: array
145+
observedGeneration:
146+
description: ObservedGeneration is the generation of the HTTPBootConfig
147+
that was last reconciled by the controller.
148+
format: int64
149+
type: integer
145150
state:
146151
type: string
147152
type: object

dist/chart/templates/crd/boot.ironcore.dev_ipxebootconfigs.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ spec:
171171
- type
172172
type: object
173173
type: array
174+
observedGeneration:
175+
description: ObservedGeneration is the generation of the IPXEBootConfig
176+
that was last reconciled by the controller.
177+
format: int64
178+
type: integer
174179
state:
175180
description: 'Important: Run "make" to regenerate code after modifying
176181
this file'

docs/api-reference/api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ _Appears in:_
8686
| Field | Description | Default | Validation |
8787
| --- | --- | --- | --- |
8888
| `state` _[HTTPBootConfigState](#httpbootconfigstate)_ | | | |
89+
| `observedGeneration` _integer_ | ObservedGeneration is the generation of the HTTPBootConfig that was last reconciled by the controller. | | |
8990
| `conditions` _[Condition](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.35/#condition-v1-meta) array_ | Conditions represent the latest available observations of the IPXEBootConfig's state | | |
9091

9192

@@ -164,6 +165,7 @@ _Appears in:_
164165
| Field | Description | Default | Validation |
165166
| --- | --- | --- | --- |
166167
| `state` _[IPXEBootConfigState](#ipxebootconfigstate)_ | Important: Run "make" to regenerate code after modifying this file | | |
168+
| `observedGeneration` _integer_ | ObservedGeneration is the generation of the IPXEBootConfig that was last reconciled by the controller. | | |
167169
| `conditions` _[Condition](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.35/#condition-v1-meta) array_ | Conditions represent the latest available observations of the IPXEBootConfig's state | | |
168170

169171

internal/controller/httpbootconfig_controller.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,13 @@ func (r *HTTPBootConfigReconciler) delete(_ context.Context, log logr.Logger, _
9595
}
9696

9797
func (r *HTTPBootConfigReconciler) patchStatus(ctx context.Context, config *bootv1alpha1.HTTPBootConfig, state bootv1alpha1.HTTPBootConfigState) error {
98-
if config.Status.State == state {
98+
if config.Status.State == state && config.Status.ObservedGeneration == config.Generation {
9999
return nil
100100
}
101101

102102
base := config.DeepCopy()
103103
config.Status.State = state
104+
config.Status.ObservedGeneration = config.Generation
104105

105106
if err := r.Status().Patch(ctx, config, client.MergeFrom(base)); err != nil {
106107
return err

internal/controller/ipxebootconfig_controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ func (r *IPXEBootConfigReconciler) patchStatus(
100100
) error {
101101
base := ipxeBootConfig.DeepCopy()
102102
ipxeBootConfig.Status.State = state
103+
ipxeBootConfig.Status.ObservedGeneration = ipxeBootConfig.Generation
103104

104105
if err := r.Status().Patch(ctx, ipxeBootConfig, client.MergeFrom(base)); err != nil {
105106
return fmt.Errorf("error patching ipxeBootConfig: %w", err)

internal/controller/serverbootconfiguration_http_controller.go

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,22 +161,34 @@ func (r *ServerBootConfigurationHTTPReconciler) patchHTTPBootReadyConditionFromH
161161
}
162162
base := cur.DeepCopy()
163163

164+
if cur.Generation != cfg.Generation {
165+
// The SBC has been updated since this reconcile started; a newer reconcile
166+
// will handle the fresh generation. Avoid stamping stale data on it.
167+
return nil
168+
}
169+
164170
cond := metav1.Condition{
165-
Type: HTTPBootReadyConditionType,
166-
ObservedGeneration: cur.Generation,
171+
Type: HTTPBootReadyConditionType,
172+
// Use cfg.Generation, not cur.Generation: the condition content was
173+
// derived from cfg's HTTPBootConfig, so it reflects that generation.
174+
ObservedGeneration: cfg.Generation,
167175
}
168-
switch httpBootConfig.Status.State {
169-
case bootv1alpha1.HTTPBootConfigStateReady:
176+
switch {
177+
case httpBootConfig.Status.ObservedGeneration < httpBootConfig.Generation:
178+
// Child controller hasn't reconciled the new spec yet; don't write anything.
179+
// The Owns() watch will re-trigger this reconcile once the child updates its status.
180+
return nil
181+
case httpBootConfig.Status.State == bootv1alpha1.HTTPBootConfigStateReady:
170182
cond.Status = metav1.ConditionTrue
171183
cond.Reason = "BootConfigReady"
172184
cond.Message = "HTTP boot configuration is ready."
173-
case bootv1alpha1.HTTPBootConfigStateError:
185+
case httpBootConfig.Status.State == bootv1alpha1.HTTPBootConfigStateError:
174186
cond.Status = metav1.ConditionFalse
175187
cond.Reason = "BootConfigError"
176188
cond.Message = "HTTPBootConfig reported an error."
177189
default:
178190
cond.Status = metav1.ConditionUnknown
179-
cond.Reason = "BootConfigPending"
191+
cond.Reason = BootConfigPendingReason
180192
cond.Message = "Waiting for HTTPBootConfig to become Ready."
181193
}
182194

0 commit comments

Comments
 (0)