mirror of
https://github.com/microsoft/onefuzz.git
synced 2025-06-16 20:08:09 +00:00
handle azure-storage deleting nonexistent containers (#948)
This commit is contained in:
@ -10,7 +10,7 @@ import urllib.parse
|
||||
from typing import Dict, Optional, Union, cast
|
||||
|
||||
from azure.common import AzureHttpError, AzureMissingResourceHttpError
|
||||
from azure.core.exceptions import ResourceExistsError
|
||||
from azure.core.exceptions import ResourceExistsError, ResourceNotFoundError
|
||||
from azure.storage.blob import (
|
||||
BlobClient,
|
||||
BlobSasPermissions,
|
||||
@ -146,12 +146,16 @@ def create_container(
|
||||
|
||||
def delete_container(container: Container, storage_type: StorageType) -> bool:
|
||||
accounts = get_accounts(storage_type)
|
||||
deleted = False
|
||||
for account in accounts:
|
||||
service = get_blob_service(account)
|
||||
if bool(service.delete_container(container)):
|
||||
return True
|
||||
try:
|
||||
service.delete_container(container)
|
||||
deleted = True
|
||||
except ResourceNotFoundError:
|
||||
pass
|
||||
|
||||
return False
|
||||
return deleted
|
||||
|
||||
|
||||
def get_container_sas_url_service(
|
||||
|
Reference in New Issue
Block a user