From 3e5b7d4992b9551361a9d163531b800b853be02f Mon Sep 17 00:00:00 2001 From: Szilard Parrag Date: Fri, 17 Nov 2023 16:39:55 +0100 Subject: [PATCH] fix(reconciler): make sure to not update the original object MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the original object contains a pointer, then without this patch that pointer will (inadvertently) change. Co-authored-by: Dudás Ádám Signed-off-by: Szilard Parrag --- pkg/resources/model/reconciler.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/resources/model/reconciler.go b/pkg/resources/model/reconciler.go index c88c4b998..f9563d080 100644 --- a/pkg/resources/model/reconciler.go +++ b/pkg/resources/model/reconciler.go @@ -277,7 +277,8 @@ func NewValidationReconciler( continue } - if err := repo.Status().Patch(ctx, req.Obj, req.Patch); err != nil { + obj := req.Obj.DeepCopyObject().(client.Object) // copy object so that the original is not changed by the call to Patch + if err := repo.Status().Patch(ctx, obj, req.Patch); err != nil { errs = errors.Append(errs, err) } }