fix(workload-monitor): use fresh spec for MinReplicas check on retry
Inside the RetryOnConflict block, derive the operational status from fresh.Spec.MinReplicas instead of the stale monitor.Spec.MinReplicas so that concurrent spec updates observed by the retry are respected. Assisted-By: Claude <noreply@anthropic.com> Signed-off-by: Aleksei Sviridkin <f@lex.la>
This commit is contained in:
parent
1bae0775be
commit
dc3387c635
1 changed files with 4 additions and 2 deletions
|
|
@ -388,9 +388,11 @@ func (r *WorkloadMonitorReconciler) Reconcile(ctx context.Context, req ctrl.Requ
|
|||
fresh.Status.ObservedReplicas = observedReplicas
|
||||
fresh.Status.AvailableReplicas = availableReplicas
|
||||
|
||||
// Default to operational = true, but check MinReplicas if set
|
||||
// Default to operational = true, but check MinReplicas if set.
|
||||
// Use fresh.Spec to avoid making decisions based on a stale cached copy
|
||||
// when the spec was updated between the initial read and this retry.
|
||||
fresh.Status.Operational = pointer.Bool(true)
|
||||
if monitor.Spec.MinReplicas != nil && availableReplicas < *monitor.Spec.MinReplicas {
|
||||
if fresh.Spec.MinReplicas != nil && availableReplicas < *fresh.Spec.MinReplicas {
|
||||
fresh.Status.Operational = pointer.Bool(false)
|
||||
}
|
||||
return r.Status().Update(ctx, fresh)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue