@@ -172,22 +172,23 @@ func defaultPhaseUpdateFunc[Obj client.Object, PhType ~string, ConType comparabl
172172// UpdateStatus updates the status of the object in the given ReconcileResult, using the previously set field names and functions. 
173173// The object is expected to be a pointer to a struct with the status field. 
174174// If the 'Object' field in the ReconcileResult is nil, the status update becomes a no-op. 
175- func  (s  * statusUpdater [Obj , PhType , ConType ]) UpdateStatus (ctx  context.Context , c  client.Client , rr  ReconcileResult [Obj , ConType ]) error  {
175+ func  (s  * statusUpdater [Obj , PhType , ConType ]) UpdateStatus (ctx  context.Context , c  client.Client , rr  ReconcileResult [Obj , ConType ]) (ctrl. Result ,  error )  {
176176	if  IsNil (rr .Object ) {
177- 		return  nil 
177+ 		return  rr . Result ,  nil 
178178	}
179179	if  s .fieldNames [STATUS_FIELD ] ==  ""  {
180- 		return  nil 
180+ 		return  rr . Result ,  nil 
181181	}
182182	if  IsNil (rr .OldObject ) ||  IsSameObject (rr .OldObject , rr .Object ) {
183183		// create old object based on given one 
184184		rr .OldObject  =  rr .Object .DeepCopyObject ().(Obj )
185185	}
186186	status  :=  GetField (rr .Object , s .fieldNames [STATUS_FIELD ], true )
187187	if  IsNil (status ) {
188- 		return  fmt .Errorf ("unable to get pointer to status field '%s' of object %T" , s .fieldNames [STATUS_FIELD ], rr .Object )
188+ 		return  rr . Result ,  fmt .Errorf ("unable to get pointer to status field '%s' of object %T" , s .fieldNames [STATUS_FIELD ], rr .Object )
189189	}
190190
191+ 	errs  :=  errors .NewReasonableErrorList (rr .ReconcileError )
191192	now  :=  time .Now ()
192193	if  s .fieldNames [STATUS_FIELD_LAST_RECONCILE_TIME ] !=  ""  {
193194		SetField (status , s .fieldNames [STATUS_FIELD_LAST_RECONCILE_TIME ], metav1 .NewTime (now ))
@@ -232,21 +233,23 @@ func (s *statusUpdater[Obj, PhType, ConType]) UpdateStatus(ctx context.Context,
232233	if  s .fieldNames [STATUS_FIELD_PHASE ] !=  ""  {
233234		phase , err  :=  s .phaseUpdateFunc (rr .Object , rr )
234235		if  err  !=  nil  {
235- 			return  fmt .Errorf ("error computing phase: %w" , err )
236+ 			phase , _  =  defaultPhaseUpdateFunc [Obj , PhType , ConType ](rr .Object , rr )
237+ 			errs .Append (fmt .Errorf ("error computing phase: %w" , err ))
236238		}
237239		SetField (status , s .fieldNames [STATUS_FIELD_PHASE ], phase )
238240	}
239241	if  s .customUpdateFunc  !=  nil  {
240242		if  err  :=  s .customUpdateFunc (rr .Object , rr ); err  !=  nil  {
241- 			return   fmt .Errorf ("error performing custom status update: %w" , err )
243+ 			errs . Append ( fmt .Errorf ("error performing custom status update: %w" , err ) )
242244		}
243245	}
244246
245247	// update status in cluster 
246248	if  err  :=  c .Status ().Patch (ctx , rr .Object , client .MergeFrom (rr .OldObject )); err  !=  nil  {
247- 		return   fmt .Errorf ("error patching status: %w" , err )
249+ 		errs . Append ( fmt .Errorf ("error patching status: %w" , err ) )
248250	}
249- 	return  nil 
251+ 
252+ 	return  rr .Result , errs .Aggregate ()
250253}
251254
252255// GetField returns the value of the field with the given name from the given object. 
0 commit comments