Skip to content

Commit afcfc3e

Browse files
authored
[Datalake][Exception]Throw DataLakeAclChangeFailedError (#14129)
* [Datalake][Exception]Throw DataLakeAclChangeFailedError * fix pylint * fix pylint
1 parent be76bc4 commit afcfc3e

8 files changed

+2542
-9
lines changed

sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
ArrowDialect,
3333
ArrowType,
3434
DataLakeFileQueryError,
35+
DataLakeAclChangeFailedError,
3536
AccessControlChangeResult,
3637
AccessControlChangeCounters,
3738
AccessControlChangeFailure,
@@ -84,6 +85,8 @@
8485
'StorageStreamDownloader',
8586
'DelimitedTextDialect',
8687
'DelimitedJsonDialect',
88+
'DataLakeFileQueryError',
89+
'DataLakeAclChangeFailedError',
8790
'ArrowDialect',
8891
'ArrowType',
8992
'DataLakeFileQueryError'

sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_models.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,3 +648,20 @@ def __init__(self, batch_counters, aggregate_counters, batch_failures, continuat
648648
self.aggregate_counters = aggregate_counters
649649
self.batch_failures = batch_failures
650650
self.continuation = continuation
651+
652+
653+
class DataLakeAclChangeFailedError(Exception):
654+
"""The error happened during set/update/remove acl recursive operation.
655+
656+
:ivar ~azure.core.exceptions.AzureError error:
657+
The exception.
658+
:ivar str description:
659+
A description of the error.
660+
:ivar str continuation:
661+
An opaque continuation token that may be used to resume the operations in case of failures.
662+
"""
663+
664+
def __init__(self, error, description, continuation):
665+
self.error = error
666+
self.description = description
667+
self.continuation = continuation

sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_path_client.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@
1212

1313
import six
1414

15+
from azure.core.exceptions import AzureError
1516
from azure.storage.blob import BlobClient
1617
from ._data_lake_lease import DataLakeLeaseClient
1718
from ._deserialize import process_storage_error
1819
from ._generated import DataLakeStorageClient
1920
from ._generated.models import StorageErrorException
2021
from ._models import LocationMode, DirectoryProperties, AccessControlChangeResult, AccessControlChanges, \
21-
AccessControlChangeCounters, AccessControlChangeFailure
22+
AccessControlChangeCounters, AccessControlChangeFailure, DataLakeAclChangeFailedError
2223
from ._serialize import convert_dfs_url_to_blob_url, get_mod_conditions, \
2324
get_path_http_headers, add_metadata_headers, get_lease_id, get_source_mod_conditions, get_access_conditions
2425
from ._shared.base_client import StorageAccountHostsMixin, parse_query
@@ -612,8 +613,8 @@ def _set_access_control_internal(self, options, progress_hook, max_batches=None)
612613
failure_count=total_failure_count),
613614
continuation=last_continuation_token
614615
if total_failure_count > 0 and not continue_on_failure else current_continuation_token)
615-
except StorageErrorException as error:
616-
process_storage_error(error)
616+
except AzureError as error:
617+
raise DataLakeAclChangeFailedError(error, error.message, last_continuation_token)
617618

618619
def _rename_path_options(self, rename_source, content_settings=None, metadata=None, **kwargs):
619620
# type: (Optional[ContentSettings], Optional[Dict[str, str]], **Any) -> Dict[str, Any]

sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_path_client_async.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
# license information.
55
# --------------------------------------------------------------------------
66
# pylint: disable=invalid-overridden-method
7+
from azure.core.exceptions import AzureError
78
from azure.storage.blob.aio import BlobClient
89
from .._shared.base_client_async import AsyncStorageAccountHostsMixin
910
from .._path_client import PathClient as PathClientBase
1011
from .._models import DirectoryProperties, AccessControlChangeResult, AccessControlChangeFailure, \
11-
AccessControlChangeCounters, AccessControlChanges
12+
AccessControlChangeCounters, AccessControlChanges, DataLakeAclChangeFailedError
1213
from .._generated.aio import DataLakeStorageClient
1314
from ._data_lake_lease_async import DataLakeLeaseClient
1415
from .._generated.models import StorageErrorException
@@ -474,8 +475,8 @@ async def _set_access_control_internal(self, options, progress_hook, max_batches
474475
failure_count=total_failure_count),
475476
continuation=last_continuation_token
476477
if total_failure_count > 0 and not continue_on_failure else current_continuation_token)
477-
except StorageErrorException as error:
478-
process_storage_error(error)
478+
except AzureError as error:
479+
raise DataLakeAclChangeFailedError(error, error.message, last_continuation_token)
479480

480481
async def _rename_path(self, rename_source,
481482
**kwargs):

0 commit comments

Comments
 (0)