From 05b0c07017acf4e6d09a0566b5b031ff7821e190 Mon Sep 17 00:00:00 2001 From: prabhat khera Date: Tue, 23 Jan 2024 13:21:01 +1300 Subject: [PATCH] add retires in updator code --- kubernetes/update.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/kubernetes/update.go b/kubernetes/update.go index f25d30f..d51fc5f 100644 --- a/kubernetes/update.go +++ b/kubernetes/update.go @@ -141,7 +141,21 @@ func updateDeployment(ctx context.Context, deployCli v1.DeploymentInterface, dep Str("deploymentName", deploymentName). Msg("Waiting for deployment to complete") - return waitForDeployment(ctx, deployCli, newDeployment.Name, newDeployment.UID) + numRetries := 1 + for numRetries < 10 { + err := waitForDeployment(ctx, deployCli, newDeployment.Name, newDeployment.UID) + if err == nil { + return nil + } + + log.Warn().Err(err).Int("number of retries", numRetries).Msg("Deployment not ready yet, retrying") + numRetries++ + } + if numRetries == 10 { + return errors.New("Something went wrong, deployment not ready after 10 retries") + } + + return nil } func waitForDeployment(ctx context.Context, deployCli v1.DeploymentInterface, deploymentName string, uid types.UID) error {