Skip to content

Commit 0b4afa4

Browse files
committed
Review comments
1 parent 6f510fd commit 0b4afa4

11 files changed

+45
-7
lines changed

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: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,16 @@ func (r *ServerBootConfigurationHTTPReconciler) patchHTTPBootReadyConditionFromH
165165
Type: HTTPBootReadyConditionType,
166166
ObservedGeneration: cur.Generation,
167167
}
168-
switch httpBootConfig.Status.State {
169-
case bootv1alpha1.HTTPBootConfigStateReady:
168+
switch {
169+
case httpBootConfig.Status.ObservedGeneration < httpBootConfig.Generation:
170+
cond.Status = metav1.ConditionUnknown
171+
cond.Reason = "BootConfigPending"
172+
cond.Message = "Waiting for HTTPBootConfig to reconcile the new spec."
173+
case httpBootConfig.Status.State == bootv1alpha1.HTTPBootConfigStateReady:
170174
cond.Status = metav1.ConditionTrue
171175
cond.Reason = "BootConfigReady"
172176
cond.Message = "HTTP boot configuration is ready."
173-
case bootv1alpha1.HTTPBootConfigStateError:
177+
case httpBootConfig.Status.State == bootv1alpha1.HTTPBootConfigStateError:
174178
cond.Status = metav1.ConditionFalse
175179
cond.Reason = "BootConfigError"
176180
cond.Message = "HTTPBootConfig reported an error."

0 commit comments

Comments
 (0)