Files
cozystack/internal/backupcontroller
Andrey Kolkov dbc088f862 fix(backups): enforce the Velero deletion backoff of failed BackupJobs
The retry backoff of the failed-job sweep only set RequeueAfter. Writing the
retry counter onto the BackupJob triggers a reconcile at once, since the
BackupJob watch has no predicate. When Velero processes a request instantly,
as it does when the backup storage location is missing or read-only, that
reconcile replaced the request again, emitted another event and raised the
counter without any wait. The sweep now records when it last created a
request, in the backups.cozystack.io/velero-deletion-attempted-at annotation,
and replaces a processed request only after the backoff for the current
count has passed since then. Before that, it requeues for the remaining
time.

A request Velero never processes, because Velero is down, and a Velero
backup stuck in New or with no phase were checked at a fixed interval,
each check with an uncached list of Backups. They are now checked again
after as long as they have already waited, from the request's or the
backup's creation time, capped at one hour. Waiting emits no event.

Recording the attempt can fail after the request was created. If the job
was deleted meanwhile, the sweep ends without an error. Any other error is
logged and the computed requeue is kept, because failing the reconcile
would only retry sooner.

Unit tests drive the clock through two back-to-back reconciles of an
instantly processed request (one replacement, one event), then three
retries at 10, 20 and 40 minutes. They also check the waiting intervals for
requests and backups of different ages, and both annotation write errors.

Refs: #5355
Assisted-by: LLM
Signed-off-by: Andrey Kolkov <androndo@gmail.com>
2026-11-19 21:07:17 +07:00
..