Skip to content

Commit

Permalink
add retires in updator code
Browse files Browse the repository at this point in the history
  • Loading branch information
prabhat83 committed Jan 23, 2024
1 parent d4607c2 commit 05b0c07
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion kubernetes/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 05b0c07

Please sign in to comment.