pub async fn retry_api_call<T, F, Fut>(
operation: F,
operation_name: &str,
) -> Result<T>Expand description
Retry a Kubernetes API call with exponential backoff.
Automatically retries on transient errors (HTTP 429, 5xx) and fails immediately on permanent errors (4xx client errors except 429).
§Arguments
operation- Async function that performs the API calloperation_name- Human-readable name for logging (e.g., “get cluster”)
§Returns
Result of the API call after retries
§Errors
Returns error if:
- Non-retryable error encountered (4xx client error)
- Max elapsed time exceeded (5 minutes)
- All retries exhausted
§Example
use kube::{Api, Client};
use bindy::crd::Bind9Cluster;
use bindy::reconcilers::retry::retry_api_call;
let client = Client::try_default().await?;
let api: Api<Bind9Cluster> = Api::namespaced(client, "default");
let cluster = retry_api_call(
|| async { api.get("my-cluster").await.map_err(Into::into) },
"get cluster my-cluster"
).await?;