From fcfa54fb1dde3719fe8c795dd683a8eed567d0d9 Mon Sep 17 00:00:00 2001 From: Manuel Riezebosch Date: Fri, 31 Aug 2018 01:28:15 +0200 Subject: [PATCH] [azure-arm] retry cleanup individual resources on error --- .../azure/arm/step_delete_resource_group.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/builder/azure/arm/step_delete_resource_group.go b/builder/azure/arm/step_delete_resource_group.go index c5b92fcf1..29e881f38 100644 --- a/builder/azure/arm/step_delete_resource_group.go +++ b/builder/azure/arm/step_delete_resource_group.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/hashicorp/packer/builder/azure/common/constants" + retry "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" ) @@ -93,11 +94,19 @@ func (s *StepDeleteResourceGroup) deleteDeploymentResources(ctx context.Context, resourceType, resourceName)) - err := deleteResource(ctx, s.client, - resourceType, - resourceName, - resourceGroupName) - s.reportIfError(err, resourceName) + err := retry.Retry(10, 600, 10, func(attempt uint) (bool, error) { + err := deleteResource(ctx, s.client, + resourceType, + resourceName, + resourceGroupName) + if err != nil { + s.reportIfError(err, resourceName) + return false, nil + } + + return true, nil + }) + if err = deploymentOperations.Next(); err != nil { return err }