Skip to content

Commit 9e97f84

Browse files
committed
handle NotFoundError from kc.Status().Patch() for deleted resource
1 parent a8c633c commit 9e97f84

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

pkg/runtime/reconciler.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -507,12 +507,15 @@ func (r *resourceReconciler) patchResourceStatus(
507507
latest.RuntimeObject(),
508508
client.MergeFrom(desired.DeepCopy().RuntimeObject()),
509509
)
510-
rlog.Exit("kc.Patch (status)", err)
511-
if err != nil {
512-
return err
510+
if err == nil {
511+
rlog.Debug("patched resource status")
512+
} else if apierrors.IsNotFound(err) {
513+
// reset the NotFound error so it is not printed in controller logs
514+
// providing false positive error
515+
err = nil
513516
}
514-
rlog.Debug("patched resource status", "latest", latest)
515-
return nil
517+
rlog.Exit("kc.Patch (status)", err)
518+
return err
516519
}
517520

518521
// deleteResource ensures that the supplied AWSResource's backing API resource
@@ -723,7 +726,7 @@ func (r *resourceReconciler) HandleReconcileError(
723726
// PatchStatus even when resource is unmanaged. This helps in setting
724727
// conditions when resolving resource-reference fails, which happens
725728
// before resource is marked as managed.
726-
// It is okay to patch status when resource is unmanaged due to deletion
729+
// It is okay to patch status when resource is not present due to deletion
727730
// because a NotFound error is thrown which will be ignored.
728731
//
729732
// TODO(jaypipes): We ignore error handling here but I don't know if

0 commit comments

Comments
 (0)