@@ -112,9 +112,11 @@ func (r *NUMAResourcesSchedulerReconciler) Reconcile(ctx context.Context, req ct
112
112
return ctrl.Result {}, err
113
113
}
114
114
115
+ initialStatus := * instance .Status .DeepCopy ()
116
+
115
117
if req .Name != objectnames .DefaultNUMAResourcesSchedulerCrName {
116
118
message := fmt .Sprintf ("incorrect NUMAResourcesScheduler resource name: %s" , instance .Name )
117
- return ctrl.Result {}, r .updateStatus (ctx , instance , status .ConditionDegraded , status .ConditionTypeIncorrectNUMAResourcesSchedulerResourceName , message )
119
+ return ctrl.Result {}, r .updateStatus (ctx , initialStatus , instance , status .ConditionDegraded , status .ConditionTypeIncorrectNUMAResourcesSchedulerResourceName , message )
118
120
}
119
121
120
122
if annotations .IsPauseReconciliationEnabled (instance .Annotations ) {
@@ -123,7 +125,7 @@ func (r *NUMAResourcesSchedulerReconciler) Reconcile(ctx context.Context, req ct
123
125
}
124
126
125
127
result , condition , err := r .reconcileResource (ctx , instance )
126
- if err := r .updateStatus (ctx , instance , condition , status .ReasonFromError (err ), status .MessageFromError (err )); err != nil {
128
+ if err := r .updateStatus (ctx , initialStatus , instance , condition , status .ReasonFromError (err ), status .MessageFromError (err )); err != nil {
127
129
klog .InfoS ("Failed to update numaresourcesscheduler status" , "Desired condition" , condition , "error" , err )
128
130
}
129
131
@@ -287,8 +289,15 @@ func platformNormalize(spec *nropv1.NUMAResourcesSchedulerSpec, platInfo Platfor
287
289
klog .V (4 ).InfoS ("SchedulerInformer default is overridden" , "Platform" , platInfo .Platform , "PlatformVersion" , platInfo .Version .String (), "SchedulerInformer" , & spec .SchedulerInformer )
288
290
}
289
291
}
290
- func (r * NUMAResourcesSchedulerReconciler ) updateStatus (ctx context.Context , sched * nropv1.NUMAResourcesScheduler , condition string , reason string , message string ) error {
291
- sched .Status .Conditions , _ = status .UpdateConditions (sched .Status .Conditions , condition , reason , message )
292
+ func (r * NUMAResourcesSchedulerReconciler ) updateStatus (ctx context.Context , initialStatus nropv1.NUMAResourcesSchedulerStatus , sched * nropv1.NUMAResourcesScheduler , condition string , reason string , message string ) error {
293
+ updatedStatus := * sched .Status .DeepCopy ()
294
+
295
+ updatedStatus .Conditions , _ = status .UpdateConditions (sched .Status .Conditions , condition , reason , message )
296
+ if ! status .NUMAResourcesSchedulerNeedsUpdate (initialStatus , updatedStatus ) {
297
+ return nil
298
+ }
299
+
300
+ sched .Status .Conditions = updatedStatus .Conditions
292
301
if err := r .Client .Status ().Update (ctx , sched ); err != nil {
293
302
return fmt .Errorf ("could not update status for object %s: %w" , client .ObjectKeyFromObject (sched ), err )
294
303
}
0 commit comments