Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add backoff to operator retry mechanism #650

Merged
merged 12 commits into from
Aug 8, 2024
12 changes: 12 additions & 0 deletions src/pepr/operator/reconcilers/package-reconciler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ export async function packageReconciler(pkg: UDSPackage) {
return;
}

if (pkg.status?.retryAttempt && pkg.status?.retryAttempt > 0) {
// calculate exponential backoff where backoffSeconds = 3^retryAttempt
const backOffSeconds = 3 ** pkg.status?.retryAttempt;

log.info(
metadata,
`Waiting ${backOffSeconds} seconds before processing Package ${namespace}/${name}, status.phase: ${pkg.status?.phase}, observedGeneration: ${pkg.status?.observedGeneration}, retryAttempt: ${pkg.status?.retryAttempt}`,
);
// wait for backOff seconds before retrying
await new Promise(resolve => setTimeout(resolve, backOffSeconds * 1000));
}

// Migrate the package to the latest version
migrate(pkg);

Expand Down