Skip to content

Commit

Permalink
fix(appset): migrateStatus updates appset pointer after updating (#19619
Browse files Browse the repository at this point in the history
)

# Context:
  `migrateStatus` updates the status of the appset but after succeeding
  it does not update the in memory object which means that that new
  updates may fail due to conflict since it's comparing it to the
  object previous to updating it in `migrateStatus`.

  # What does this PR?
  - After updating the appset object in `migrateStatus` it gets the
    object again to reference it in the appset pointer of the
    reconciler.

Signed-off-by: Carlos Rejano <carlosrejanoromeu@gmail.com>
  • Loading branch information
carlosrejano authored Aug 22, 2024
1 parent 0179805 commit 5dd6020
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions applicationset/controllers/applicationset_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1268,9 +1268,16 @@ func (r *ApplicationSetReconciler) migrateStatus(ctx context.Context, appset *ar
}

if update {
namespacedName := types.NamespacedName{Namespace: appset.Namespace, Name: appset.Name}
if err := r.Client.Status().Update(ctx, appset); err != nil {
return fmt.Errorf("unable to set application set status: %w", err)
}
if err := r.Get(ctx, namespacedName, appset); err != nil {
if client.IgnoreNotFound(err) != nil {
return nil
}
return fmt.Errorf("error fetching updated application set: %w", err)
}
}
return nil
}
Expand Down

0 comments on commit 5dd6020

Please # to comment.