<p>I am building a Go Kubernetes operator. I have used kubebuilder to create it.
I want to store some internal details in the CRD status. I have tried :</p>
<ul>
<li>To update the whole resource :</li>
</ul>
<pre><code>if err = r.Client.Update(ctx, upCRD); err != nil {
    return ctrl.Result{}, client.IgnoreNotFound(err)
}
</code></pre>
<ul>
<li>And to update only the status :</li>
</ul>
<pre><code>if err = r.Status().Update(ctx, upCRD); err != nil {
    return reconcile.Result{}, client.IgnoreNotFound(err)
}
</code></pre>
<p>The status struct is defined as follows :</p>
<pre><code>type HAAuditStatus struct {
    ChaosStrategyCron  cron.EntryID       `json:&quot;chaosStrategyCron,omitempty&quot;`
    TestStatus         TestStatus         `json:&quot;testStatus,omitempty&quot;`
    MetricStatus       MetricStatus       `json:&quot;metricStatus,omitempty&quot;`
    RoundRobinStrategy RoundRobinStrategy `json:&quot;roundRobinStrategy,omitempty&quot;`
    FixedStrategy      FixedStrategy      `json:&quot;fixedStrategy,omitempty&quot;`
    NextChaosDateTime  int64              `json:&quot;nextChaosDateTime,omitempty&quot;`
    Created            bool               `json:&quot;created,default=false&quot;`
}
</code></pre>
<p>No error is raised and the specs fields modified are actually persisted but not the status field whose values remain the default at the next reconciling step.
I have looked at the other issues on GitHub or StackOverflow but any suggestion made solved my issue and I can't figure out what is the problem. For a a bigger picture, you can refer to the <a href="https://github.com/PaulBarrie/ha-audit-operator" rel="nofollow noreferrer">repo</a> where the operator is located.</p>
<p>Any suggestion is very welcomed :)</p>

<p>I might have found the reason why the status were not updated.</p>
<p>Before updating the status, I was also updating the spec fields (to give some feedback to the user on created resources).</p>
<p>The issue is caused by the fact that the specs updates trigger a new reconcilation, and the instruction after this update (among them the status update) were not execute.</p>
<p>I realized that using specs to give feedback to the user is not suitable and the events were more appropriate for this purpose.</p>
