kubernetes.utils.retry module

kubernetes.utils.retry.on_error(backoff: ~kubernetes.utils._retry_base.Backoff, retriable: ~typing.Callable[[Exception], bool], fn: ~typing.Callable[[], ~kubernetes.utils.retry.T], sleep_func: ~typing.Callable[[float], None] = <built-in function sleep>, random_func: ~typing.Callable[[], float] = <built-in method random of Random object>) T

Run fn and retry while retriable returns True.

This is a 1:1 implementation of k8s.io/client-go/util/retry.OnError.

kubernetes.utils.retry.on_retry_after_error(backoff: ~kubernetes.utils._retry_base.Backoff, retriable: ~typing.Callable[[Exception], bool], fn: ~typing.Callable[[], ~kubernetes.utils.retry.T], sleep_func: ~typing.Callable[[float], None] = <built-in function sleep>, random_func: ~typing.Callable[[], float] = <built-in method random of Random object>) T

Run fn with client-go REST Retry-After sleep semantics.

This is a 1:1 implementation of the wait selection in k8s.io/client-go/rest.WithRetry: if the retriable response carries a valid Retry-After header, that delay is used; otherwise the supplied backoff delay is used.

kubernetes.utils.retry.retry_on_conflict(fn: ~typing.Callable[[], ~kubernetes.utils.retry.T], backoff: ~kubernetes.utils._retry_base.Backoff = Backoff(steps=5, duration=0.01, factor=1.0, jitter=0.1, cap=0.0), sleep_func: ~typing.Callable[[float], None] = <built-in function sleep>, random_func: ~typing.Callable[[], float] = <built-in method random of Random object>) T

Run fn and retry on HTTP 409 Conflict responses.

This is a 1:1 implementation of k8s.io/client-go/util/retry.RetryOnConflict. Callers should re-read the object inside fn before each write attempt, so every retry uses the latest resource version.