How to stop requeuing a request in reconciler in k8s controller runtime after x attempts?

214 views Asked by At

I need to recover from a reconciler that runs indefinitely after exceeding x requeues using the controller runtime framework due to failures. I do know that I can stop requeuing by using reconcile.Result{Requeue:false}, nil or set a back off using RequeueAfter. However, I need to stop and gracefully end the reconciliation after x attempts. Is there a way to accomplish this?

1

There are 1 answers

0
Thomas Barizien On

It is not possible using the reconcile.Result return value.

If you expect a specific error, just stop reconcile when this specific error happens (for example a rate limiting error).

Otherwise you'll have to implement the logic yourself, somehow storing the amount of times you've reconcile your object either inside the controller (which becomes statefull) or in a workspace object alongside the object you're reconciling.