<p>I use the patch function to devoid version check:</p>
<pre><code>svcNow := &amp;v1.Service{}
if err := s.Get(context.TODO(), event.NamespacedName, svcNow); err != nil {
    return err
}
updateSvc := svcNow.DeepCopy()
updateSvc.Annotations = newAnno
if err := s.Patch(context.TODO(), updateSvc, client.MergeFrom(svcNow)); err != nil {
    log.Info(&quot;Patch status to annotations failed&quot;, &quot;patch&quot;, string(jsonStatus))
    return err
}
</code></pre>
<p>But sometimes I would get the error <code>the object has been modified; please apply your changes to the latest version and try again</code> still.</p>
<p>Why patch return the error? I thought patch will not check the version.</p>
<p>How can I solve this problem?</p>
<p>Thanks a lot!</p>
<hr />
<p>I have get some new information!</p>
<p>If the object in server has been add some finalizer, or its status has been modified, could meet the error <code>the object has been modified; please apply your changes to the latest version and try again</code> when patch.</p>
<hr />
<p>Bad news :(</p>
<p>Status or Finalizer have been modified is not the reason why failed to patch.</p>

Wenming Chen
<p>The error <code>&quot; the object has been modified; please apply your changes to the latest version and try again&quot;</code> usually happens because we fetched the resource and stored it in a variable in our code. Then after a while, we try to update this resource using the data stored in the variable. However, between the time we used the client to receive the data and the time we attempted to update it, the state of the resource on the cluster had changed.</p>
<p>A possible solution can be to ensure that you re-fetch the resource before any update or patch.</p>
