<p>Under which conditions will client.Client return a non-nil error and the client object will be also filled (or at least the namespace and name object meta)? The Kubernetes operator framework book suggests to <a href="https://github.com/PacktPublishing/The-Kubernetes-Operator-Framework-Book/blob/main/chapter_05/controllers/nginxoperator_controller.go#L71" rel="nofollow noreferrer">set a status condition</a> in case of getting resource errors in a similar fashion:</p>
<pre class="lang-golang prettyprint-override"><code>myResource := &amp;v1alpha1.MyResource{}
err := r.Get(ctx, req.NamespacedName, myResource)
if err != nil &amp;&amp; errors.IsNotFound(err) {
    return ctrl.Result{}, nil
} else if err != nil {
    logger.Error(err, &quot;Error getting resource object&quot;)
    meta.SetStatusCondition(&amp;myResource.Status.Conditions, metav1.Condition{
        Type:               &quot;Failed&quot;,
        Status:             metav1.ConditionTrue,
        Reason:             &quot;NotAvailable&quot;,
        LastTransitionTime: metav1.NewTime(time.Now()),
        Message:            fmt.Sprintf(&quot;unable to get custom resource: %s&quot;, err.Error()),
    })
    return ctrl.Result{}, utilerrors.NewAggregate([]error{err, r.Status().Update(ctx, myResource)})
}
</code></pre>
<p>Is it even possible to update the status of a CR where we are unable to get it, but the error doesn't satisfy the condition <code>errors.IsNotFound(err)</code>?</p>

Kubus
<p>Here is the <a href="https://github.com/kubernetes/apimachinery/blob/master/pkg/api/errors/errors.go" rel="nofollow noreferrer">list of errors</a> you may get from reconciler's <code>Get()</code> method.</p>
<p>If the error is not nil, that means <strong>you most probably did not get the resource correctly, so you shouldn't update it</strong>. Say that your error is <code>TooManyRequests</code>. In this case, <code>errors.IsTooManyRequests(err)</code> returns <code>true</code> while <code>errors.IsNotFound(err)</code> returns <code>false</code>. The point is, there is no guarantee that you have the correct version of the custom resource if the <code>err</code> is not <code>nil</code>. You should return the error and let the controller reconcile it again.</p>
