From 1b6d635a5f3702589bbc46e32848abe9295a30fb Mon Sep 17 00:00:00 2001 From: Guilherme Cassolato Date: Mon, 4 Dec 2023 16:45:46 +0100 Subject: [PATCH] Ensure defaults and all resource mutation are considered before comparing existing vs desired state of resources when reconciling updates, by dry-running the updates before (#356) --- pkg/reconcilers/base_reconciler.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/reconcilers/base_reconciler.go b/pkg/reconcilers/base_reconciler.go index 6d8d683c4..addd9f095 100644 --- a/pkg/reconcilers/base_reconciler.go +++ b/pkg/reconcilers/base_reconciler.go @@ -126,6 +126,11 @@ func (b *BaseReconciler) ReconcileResource(ctx context.Context, obj, desired cli return b.DeleteResource(ctx, desired) } + desired.SetResourceVersion(obj.GetResourceVersion()) + if err := b.Client().Update(ctx, desired, client.DryRunAll); err != nil { + return err + } + update, err := mutateFn(obj, desired) if err != nil { return err