How to Understand Why Reconcile Was Called by Controller? #1705
-
Hello. There is a controller https://docs.rs/kube/latest/kube/runtime/controller/struct.Controller.html which can watch resource and object with ref to this resource in owner_reference. Unfortunately I failed to understand if it possible to differentiate in on_reconcile callback why it has been called? If the resource itself has been modified of the objects it owns has been changed/deleted? If it possible? E.g. If I have a resource which creates pods and one of the pod was deleted, can I see the reason in on_reconcile callback and recreate pod? Or if the pod has been modified to get the reason and revert this changes? Thank you in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Ok, by the time I went to owns/watches difference I completely forgot about this part of the doc: "This mapping mechanism ultimately hides the reason for the reconciliation request, and forces you to write an idempotent reconciler." Could you please clarify what is intended to use in such use case? watcher or reflector? Thank you in advance. |
Beta Was this translation helpful? Give feedback.
-
Short answer is you shouldn't, and instead code defensively around it because of the lack of guaranteed message delivery.
It depends. If you want guaranteed cleanup, then a finalizer gives you guaranteed delivery by blocking deletes until you remove the finalizer. If you don't want to use finalizers on an object like pods, you can put it on something else like a CRD. If you want to track progress, maybe you need to save hashes of completed objects somewhere (typically done on a crd.status object). |
Beta Was this translation helpful? Give feedback.
Short answer is you shouldn't, and instead code defensively around it because of the lack of guaranteed message delivery.
There's a paragraph in https://kube.rs/controllers/reconciler/#reasons-for-reconciliation about it.
It depends. If you want guaranteed cleanup, then a finalizer gives you guaranteed delivery by blocking deletes until you remove the finalizer. If you don't want to us…