Krikri::AptRepositoryCacheRetry
Cache-update retry behavior for the apt_repository plugin, mirroring
Ansible's own apt_repository.py update_cache_retries /
update_cache_retry_max_delay parameters (defaults 5 / 12, both
verified against the locally installed module's argument_spec).
Ansible's loop (apt_repository.py, if update_cache: block):
for retry in range(update_cache_retries) around python-apt's
Cache().update(), with delay = 2 ** retry + randomize between
attempts (randomize = secrets.randbelow(1000) / 1000.0), the delay
capped at update_cache_retry_max_delay + randomize when the
exponential term outgrows it. Same formula here.
Mixed into AptRepositoryPlugin so the retry loop is callable as a
private method, while the regression spec can require this file
directly (without firing apt_repository.cr's entry point) and drive
the loop through an injected exec_remote proc - the same pattern
AptLockRetry established for the apt plugin's own
update_cache_retries support.
Constants
Class methods
The "Sleeping for N seconds" warning's integer. Ansible does NOT
truncate the float delay (%i would give 1.7s -> "1"): both its
callers (apt_repository.py:746, apt.py:1426, ansible-core 2.19.11)
format int(round(delay)), and Python round is ties-to-even, so
1.7 -> "2", 2.5 -> "2", 3.5 -> "4". Truncating instead changes N
whenever the jitter lands in [0.5, 1.0), which changes how repeated
warnings dedupe across loop items.
Instance methods
Runs apt-get update, retrying on non-zero exit up to retries
total attempts (Ansible's range(update_cache_retries) bound)
with the exponential-backoff-with-jitter delay between attempts.
Only a non-zero exit code retries: that maps to apt's own fetch
failure, the case python-apt reports as FetchFailedException (the
only exception Ansible's loop catches). A GPG signature
warning leaves apt-get update exiting 0 - that path is handled
separately by the plugin's gpg_signature_failure? scan and, like
Ansible's non-FetchFailedException exceptions, fails without
retrying.
Backoff delay before retry number retry (0-based), matching
Ansible's delay = 2 ** retry + randomize capped at
update_cache_retry_max_delay + randomize. jitter is injectable
so the regression spec can pin the value; defaults to the same
0..1 random fraction Ansible uses.