Replies: 3 comments 4 replies
-
In the context of Kubernetes and controllers built using kubebuilder, when an object is updated, the reconciler is triggered with the current state of the object. The previous state of the object is not automatically provided. You might find ways to do so, by for example storing the old state. Not sure if that would be an ideal approach. |
Beta Was this translation helpful? Give feedback.
-
@camilamacedo86 Thanks for the reply and this was opened last year. What I did was store the objects in the operator and compare the generation field whenever a reconcile happens to know whether the operator has the latest version or not. Works well for my use case without any issue. Thanks for the response. |
Beta Was this translation helpful? Give feedback.
-
Hi @NomadXD
It is a good practice to fetch the resource before updating or changing it, see the code generated when we are using the Deploy Image plugin which will add the reconciliation code for you: (so that you avoid facing the error: `the object has been modified, please apply // your changes to the latest version and try again") Also, note that K8s stores the old version of the resource in the annotations. It seems that this one is sorted out so I am closing this discussion topic |
Beta Was this translation helpful? Give feedback.
-
For example let's say I have a resource and then I update it. I get the reconcile request with name and namespace.
I can access the object with r.Get() in the reconciler.
But how to get the previous state of that object ?
Beta Was this translation helpful? Give feedback.
All reactions