Handle lease not present error

This commit is contained in:
Wilken Rivera 2020-08-12 11:27:07 -04:00
parent d91839b93e
commit 5700f74c8c
2 changed files with 6 additions and 6 deletions

View File

@ -35,12 +35,13 @@ func NewStepDeleteAdditionalDisks(client *AzureClient, ui packer.Ui) *StepDelete
func (s *StepDeleteAdditionalDisk) deleteBlob(storageContainerName string, blobName string) error {
blob := s.client.BlobStorageClient.GetContainerReference(storageContainerName).GetBlobReference(blobName)
if _, err := blob.BreakLease(nil); err != nil {
_, err := blob.BreakLease(nil)
if err != nil && !strings.Contains(err.Error(), "LeaseNotPresentWithLeaseOperation") {
s.say(s.client.LastError.Error())
return err
}
err := blob.Delete(nil)
err = blob.Delete(nil)
if err != nil {
s.say(s.client.LastError.Error())
}

View File

@ -258,12 +258,11 @@ func (s *StepDeployTemplate) deleteImage(ctx context.Context, imageType string,
var blobName = strings.Join(xs[2:], "/")
blob := s.client.BlobStorageClient.GetContainerReference(storageAccountName).GetBlobReference(blobName)
if _, err := blob.BreakLease(nil); err != nil {
_, err = blob.BreakLease(nil)
if err != nil && !strings.Contains(err.Error(), "LeaseNotPresentWithLeaseOperation") {
s.say(s.client.LastError.Error())
return err
}
err = blob.Delete(nil)
return err
return blob.Delete(nil)
}