Handle lease not present error
This commit is contained in:
parent
d91839b93e
commit
5700f74c8c
|
@ -35,12 +35,13 @@ func NewStepDeleteAdditionalDisks(client *AzureClient, ui packer.Ui) *StepDelete
|
||||||
|
|
||||||
func (s *StepDeleteAdditionalDisk) deleteBlob(storageContainerName string, blobName string) error {
|
func (s *StepDeleteAdditionalDisk) deleteBlob(storageContainerName string, blobName string) error {
|
||||||
blob := s.client.BlobStorageClient.GetContainerReference(storageContainerName).GetBlobReference(blobName)
|
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())
|
s.say(s.client.LastError.Error())
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err := blob.Delete(nil)
|
err = blob.Delete(nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.say(s.client.LastError.Error())
|
s.say(s.client.LastError.Error())
|
||||||
}
|
}
|
||||||
|
|
|
@ -258,12 +258,11 @@ func (s *StepDeployTemplate) deleteImage(ctx context.Context, imageType string,
|
||||||
var blobName = strings.Join(xs[2:], "/")
|
var blobName = strings.Join(xs[2:], "/")
|
||||||
|
|
||||||
blob := s.client.BlobStorageClient.GetContainerReference(storageAccountName).GetBlobReference(blobName)
|
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())
|
s.say(s.client.LastError.Error())
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = blob.Delete(nil)
|
return blob.Delete(nil)
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue