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

Always log error (if applicable) on failed deployment attempts #2933

Merged
merged 2 commits into from
Jun 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions pkg/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,19 @@ func (d *deployer) getParameters(ps map[string]interface{}) *arm.Parameters {
}

func (d *deployer) deploy(ctx context.Context, rgName, deploymentName, vmssName string, deployment mgmtfeatures.Deployment) (err error) {
for i := 0; i < 3; i++ {
numAttempts := 3

for i := 0; i < numAttempts; i++ {
d.log.Printf("deploying %s", deploymentName)
err = d.deployments.CreateOrUpdateAndWait(ctx, rgName, deploymentName, deployment)
serviceErr, isServiceError := err.(*azure.ServiceError)

// As long as this is not the final deployment attempt,
// unconditionally log the error before inspecting it.
if err != nil && i < numAttempts-1 {
d.log.Print(err)
}

// Check for a known error that we know how to handle.
if isServiceError {
errorType, checkTypeErr := d.checkForKnownError(serviceErr, i)
Expand All @@ -181,7 +189,7 @@ func (d *deployer) deploy(ctx context.Context, rgName, deploymentName, vmssName
// Retry once, and only if this error is encountered on the first
// deployment attempt.
if errorType == KnownDeploymentErrorTypeRPLBNotFound {
d.log.Print(err)
d.log.Print("Deployment encountered known ResourceNotFound error for RP LB; retrying.")
continue
}
}
Expand Down