crossplane / crossplane-runtime

A set of libraries for writing Crossplane controllers.
https://crossplane.io
Apache License 2.0
144 stars 95 forks source link

Prevent unnecessary reconciles on provider restarts #696

Open gravufo opened 1 month ago

gravufo commented 1 month ago

What problem are you facing?

Today, when provider pods are restarted (whether it's due to updates to the provider version or simply k8s nodes shuffling), the cache is completely lost forcing the controllers to reconcile all MRs regardless of the last time they were synced and the configured poll frequency.

Depending on the provider, this can be fine and fast, but can sometimes be very slow and even problematic (think external APIs rate limiting). The specific use-case I am referring to is provider-upjet-azure which easily gets rate-limited by the Azure RM API if it gets restarted when managing a large number of MRs.

How could Crossplane help solve your problem?

Since we have no choice but to requeue all objects (this makes sense), I think a nice improvement would be to validate the last time this object (assuming Synced and Ready are both true) was reconciled and calculating based on the poll frequency if it needs to be reconciled again right now or if it should be requeued at the time the poll frequency would be hit.

This would prevent mega bursts of external calls every time we need to restart provider pods, regardless of the reason.