Use the patch API instead to prevent unnecessary field updates (#1998)
Fixes #1916
This commit is contained in:
		
							parent
							
								
									154fcde7d0
								
							
						
					
					
						commit
						ae86b1a011
					
				|  | @ -190,7 +190,7 @@ func (s *batchScaler) batchScale(ctx context.Context, batch batchScaleOperation) | ||||||
| 	after := len(copy.Spec.CapacityReservations) | 	after := len(copy.Spec.CapacityReservations) | ||||||
| 
 | 
 | ||||||
| 	s.Log.V(1).Info( | 	s.Log.V(1).Info( | ||||||
| 		fmt.Sprintf("Updating hra %s for capacityReservations update", hra.Name), | 		fmt.Sprintf("Patching hra %s for capacityReservations update", hra.Name), | ||||||
| 		"before", before, | 		"before", before, | ||||||
| 		"expired", expired, | 		"expired", expired, | ||||||
| 		"added", added, | 		"added", added, | ||||||
|  | @ -198,8 +198,8 @@ func (s *batchScaler) batchScale(ctx context.Context, batch batchScaleOperation) | ||||||
| 		"after", after, | 		"after", after, | ||||||
| 	) | 	) | ||||||
| 
 | 
 | ||||||
| 	if err := s.Client.Update(ctx, copy); err != nil { | 	if err := s.Client.Patch(ctx, copy, client.MergeFrom(&hra)); err != nil { | ||||||
| 		return fmt.Errorf("updating horizontalrunnerautoscaler to add capacity reservation: %w", err) | 		return fmt.Errorf("patching horizontalrunnerautoscaler to add capacity reservation: %w", err) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	return nil | 	return nil | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue