From a93011ae97ef2de5af5198a593df3a827275fae5 Mon Sep 17 00:00:00 2001 From: Gerrit Date: Tue, 8 Feb 2022 09:41:56 +0100 Subject: [PATCH] Retrieve resource version. --- controllers/resources.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/controllers/resources.go b/controllers/resources.go index a0a570b..75bb86d 100644 --- a/controllers/resources.go +++ b/controllers/resources.go @@ -1042,6 +1042,13 @@ func (r *DurosReconciler) createOrUpdate(ctx context.Context, obj client.Object) err := r.Shoot.Create(ctx, obj) if err != nil { if apierrors.IsAlreadyExists(err) { + part := &metav1.PartialObjectMetadata{} + part.SetGroupVersionKind(obj.GetObjectKind().GroupVersionKind()) + err = r.Shoot.Get(ctx, client.ObjectKeyFromObject(obj), part) + if err != nil { + return err + } + obj.SetResourceVersion(part.ResourceVersion) return r.Shoot.Update(ctx, obj) } return err