Skip to content

Commit

Permalink
Lucas's final feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
JenGoldstrich committed Apr 29, 2024
1 parent 128e87d commit 0eebcbe
Showing 1 changed file with 5 additions and 21 deletions.
26 changes: 5 additions & 21 deletions builder/azure/arm/step_deploy_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,8 @@ func (s *StepDeployTemplate) retryDeletion(ctx context.Context, resourceType str
})
if err != nil {
s.reportResourceDeletionFailure(err, resourceName)
} else {
s.say(fmt.Sprintf("Deleted -> %s : '%s'", resourceType, resourceName))
}
return err

Expand Down Expand Up @@ -397,38 +399,20 @@ func (s *StepDeployTemplate) listDeploymentOperations(ctx context.Context, id de
// This function is called to delete the resources remaining in the deployment after we delete the Virtual Machine and the deleteNic
// These resources before the VM and the NIC results in errors
func (s *StepDeployTemplate) deleteDetatchedResourcesWithQueue(ctx context.Context, subscriptionId string, resourceGroupName string, resources map[string]string) error {
retryConfig := retry.Config{
Tries: 5,
RetryDelay: (&retry.Backoff{
InitialBackoff: 3 * time.Second,
MaxBackoff: 15 * time.Second,
Multiplier: 1.5,
}).Linear,
}
var wg sync.WaitGroup
wg.Add(len(resources))

for resourceType, resourceName := range resources {
go func(resourceType, resourceName string) {
defer wg.Done()

err := retryConfig.Run(ctx, func(ctx context.Context) error {
log.Printf("[INFO} Attempting deletion -> %s : '%s'", resourceType, resourceName)
err := deleteResource(ctx, s.client,
s.retryDeletion(ctx, resourceName, resourceType, func() error {

Check failure on line 408 in builder/azure/arm/step_deploy_template.go

View workflow job for this annotation

GitHub Actions / Lint check

Error return value of `s.retryDeletion` is not checked (errcheck)
return deleteResource(ctx, s.client,
subscriptionId,
resourceType,
resourceName,
resourceGroupName)
if err != nil {
log.Printf("[INFO] Couldn't delete resource %s.%s, will retry", resourceType, resourceName)
} else {
s.say(fmt.Sprintf("Deleted -> %s : '%s'", resourceType, resourceName))
}
return err
})
if err != nil {
s.reportResourceDeletionFailure(err, resourceName)
}

}(resourceType, resourceName)
}

Expand Down

0 comments on commit 0eebcbe

Please sign in to comment.