From 86704a8e7afbaa184fb4c0399f3295f332f94203 Mon Sep 17 00:00:00 2001 From: michaelhtm <98621731+michaelhtm@users.noreply.github.com> Date: Fri, 25 Apr 2025 14:39:32 -0700 Subject: [PATCH] fix: patch metadata and spec during Adopt adoption Currently, when adoptionPolicy is `adopt`, when you call ReadOne and there's an error, if the error is not a NotFound error, the Spec fields do not get patched. These changes ensure if the resource is found, even with errors, we patch the Spec with latest fields --- pkg/runtime/reconciler.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/runtime/reconciler.go b/pkg/runtime/reconciler.go index 75ad3f6..07cbe1f 100644 --- a/pkg/runtime/reconciler.go +++ b/pkg/runtime/reconciler.go @@ -466,6 +466,12 @@ func (r *resourceReconciler) Sync( rlog.Exit("rm.ReadOne", err) if err != nil { if err != ackerr.NotFound { + if adoptionPolicy == AdoptionPolicy_Adopt && latest != nil { + latest, err = r.patchResourceMetadataAndSpec(ctx, rm, desired, latest) + if err != nil { + return latest, err + } + } return latest, err } if adoptionPolicy == AdoptionPolicy_Adopt || isAdopted {