From 8cc14551988d12b5ea2b8a58769ab427eb6bb32e Mon Sep 17 00:00:00 2001 From: Carlos Rejano Date: Wed, 21 Aug 2024 18:48:46 +0200 Subject: [PATCH] fix(appset): `setApplicationSetStatusCondition` updates appset in memory # Context: `setApplicationSetStatusCondition` function does not update the appset in memory after updating it in the cluster, this means that new updates using the appset object in memory may fail due to conflict. Before it was not an issue since `setApplicationSetStatusCondition` was almost always used before finishing the reconcile so no new updates were done. Now this function is also used when performing progressive syncs as introduced in this PR: https://github.com/argoproj/argo-cd/pull/19473 So it's very likely that a new update after this function so new updates may fail due to conflict. # What does this PR? - After updating the appset object in `setApplicationSetStatusCondition` it gets the object again to reference it in the appset pointer of the reconciler. Signed-off-by: Carlos Rejano --- applicationset/controllers/applicationset_controller.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/applicationset/controllers/applicationset_controller.go b/applicationset/controllers/applicationset_controller.go index f53bfb38fdc4d..fa9292e9c07b9 100644 --- a/applicationset/controllers/applicationset_controller.go +++ b/applicationset/controllers/applicationset_controller.go @@ -442,6 +442,12 @@ func (r *ApplicationSetReconciler) setApplicationSetStatusCondition(ctx context. if err != nil && !apierr.IsNotFound(err) { return fmt.Errorf("unable to set application set condition: %w", err) } + if err := r.Get(ctx, namespacedName, applicationSet); err != nil { + if client.IgnoreNotFound(err) != nil { + return nil + } + return fmt.Errorf("error fetching updated application set: %w", err) + } } return nil