Skip to content

Commit

Permalink
Ensure defaults and all resource mutation are considered before compa…
Browse files Browse the repository at this point in the history
…ring existing vs desired state of resources when reconciling updates, by dry-running the updates before
  • Loading branch information
guicassolato committed Dec 4, 2023
1 parent 2acf31b commit 6a2200c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/reconcilers/base_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Check warning on line 132 in pkg/reconcilers/base_reconciler.go

View check run for this annotation

Codecov / codecov/patch

pkg/reconcilers/base_reconciler.go#L131-L132

Added lines #L131 - L132 were not covered by tests

update, err := mutateFn(obj, desired)
if err != nil {
return err
Expand Down

0 comments on commit 6a2200c

Please sign in to comment.