@@ -122,9 +122,11 @@ func (r *NUMAResourcesSchedulerReconciler) Reconcile(ctx context.Context, req ct
122
122
return ctrl.Result {}, err
123
123
}
124
124
125
+ initialStatus := * instance .Status .DeepCopy ()
126
+
125
127
if req .Name != objectnames .DefaultNUMAResourcesSchedulerCrName {
126
128
message := fmt .Sprintf ("incorrect NUMAResourcesScheduler resource name: %s" , instance .Name )
127
- return ctrl.Result {}, r .updateStatus (ctx , instance , status .ConditionDegraded , status .ConditionTypeIncorrectNUMAResourcesSchedulerResourceName , message )
129
+ return ctrl.Result {}, r .updateStatus (ctx , initialStatus , instance , status .ConditionDegraded , status .ConditionTypeIncorrectNUMAResourcesSchedulerResourceName , message )
128
130
}
129
131
130
132
if annotations .IsPauseReconciliationEnabled (instance .Annotations ) {
@@ -133,7 +135,7 @@ func (r *NUMAResourcesSchedulerReconciler) Reconcile(ctx context.Context, req ct
133
135
}
134
136
135
137
result , condition , err := r .reconcileResource (ctx , instance )
136
- if err := r .updateStatus (ctx , instance , condition , status .ReasonFromError (err ), status .MessageFromError (err )); err != nil {
138
+ if err := r .updateStatus (ctx , initialStatus , instance , condition , status .ReasonFromError (err ), status .MessageFromError (err )); err != nil {
137
139
klog .InfoS ("Failed to update numaresourcesscheduler status" , "Desired condition" , condition , "error" , err )
138
140
}
139
141
@@ -375,8 +377,15 @@ func platformNormalize(spec *nropv1.NUMAResourcesSchedulerSpec, platInfo Platfor
375
377
klog .V (4 ).InfoS ("SchedulerInformer default is overridden" , "Platform" , platInfo .Platform , "PlatformVersion" , platInfo .Version .String (), "SchedulerInformer" , & spec .SchedulerInformer )
376
378
}
377
379
}
378
- func (r * NUMAResourcesSchedulerReconciler ) updateStatus (ctx context.Context , sched * nropv1.NUMAResourcesScheduler , condition string , reason string , message string ) error {
379
- sched .Status .Conditions , _ = status .UpdateConditions (sched .Status .Conditions , condition , reason , message )
380
+ func (r * NUMAResourcesSchedulerReconciler ) updateStatus (ctx context.Context , initialStatus nropv1.NUMAResourcesSchedulerStatus , sched * nropv1.NUMAResourcesScheduler , condition string , reason string , message string ) error {
381
+ updatedStatus := * sched .Status .DeepCopy ()
382
+
383
+ updatedStatus .Conditions , _ = status .UpdateConditions (sched .Status .Conditions , condition , reason , message )
384
+ if ! status .NUMAResourcesSchedulerNeedsUpdate (initialStatus , updatedStatus ) {
385
+ return nil
386
+ }
387
+
388
+ sched .Status .Conditions = updatedStatus .Conditions
380
389
if err := r .Client .Status ().Update (ctx , sched ); err != nil {
381
390
return fmt .Errorf ("could not update status for object %s: %w" , client .ObjectKeyFromObject (sched ), err )
382
391
}
0 commit comments