Skip to content

Commit

Permalink
[Datalake][Exception]Throw DataLakeAclChangeFailedError (#14129)
Browse files Browse the repository at this point in the history
* [Datalake][Exception]Throw DataLakeAclChangeFailedError

* fix pylint

* fix pylint
  • Loading branch information
xiafu-msft committed Oct 1, 2020
1 parent be76bc4 commit afcfc3e
Show file tree
Hide file tree
Showing 8 changed files with 2,542 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
ArrowDialect,
ArrowType,
DataLakeFileQueryError,
DataLakeAclChangeFailedError,
AccessControlChangeResult,
AccessControlChangeCounters,
AccessControlChangeFailure,
Expand Down Expand Up @@ -84,6 +85,8 @@
'StorageStreamDownloader',
'DelimitedTextDialect',
'DelimitedJsonDialect',
'DataLakeFileQueryError',
'DataLakeAclChangeFailedError',
'ArrowDialect',
'ArrowType',
'DataLakeFileQueryError'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -648,3 +648,20 @@ def __init__(self, batch_counters, aggregate_counters, batch_failures, continuat
self.aggregate_counters = aggregate_counters
self.batch_failures = batch_failures
self.continuation = continuation


class DataLakeAclChangeFailedError(Exception):
"""The error happened during set/update/remove acl recursive operation.
:ivar ~azure.core.exceptions.AzureError error:
The exception.
:ivar str description:
A description of the error.
:ivar str continuation:
An opaque continuation token that may be used to resume the operations in case of failures.
"""

def __init__(self, error, description, continuation):
self.error = error
self.description = description
self.continuation = continuation
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@

import six

from azure.core.exceptions import AzureError
from azure.storage.blob import BlobClient
from ._data_lake_lease import DataLakeLeaseClient
from ._deserialize import process_storage_error
from ._generated import DataLakeStorageClient
from ._generated.models import StorageErrorException
from ._models import LocationMode, DirectoryProperties, AccessControlChangeResult, AccessControlChanges, \
AccessControlChangeCounters, AccessControlChangeFailure
AccessControlChangeCounters, AccessControlChangeFailure, DataLakeAclChangeFailedError
from ._serialize import convert_dfs_url_to_blob_url, get_mod_conditions, \
get_path_http_headers, add_metadata_headers, get_lease_id, get_source_mod_conditions, get_access_conditions
from ._shared.base_client import StorageAccountHostsMixin, parse_query
Expand Down Expand Up @@ -612,8 +613,8 @@ def _set_access_control_internal(self, options, progress_hook, max_batches=None)
failure_count=total_failure_count),
continuation=last_continuation_token
if total_failure_count > 0 and not continue_on_failure else current_continuation_token)
except StorageErrorException as error:
process_storage_error(error)
except AzureError as error:
raise DataLakeAclChangeFailedError(error, error.message, last_continuation_token)

def _rename_path_options(self, rename_source, content_settings=None, metadata=None, **kwargs):
# type: (Optional[ContentSettings], Optional[Dict[str, str]], **Any) -> Dict[str, Any]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
# license information.
# --------------------------------------------------------------------------
# pylint: disable=invalid-overridden-method
from azure.core.exceptions import AzureError
from azure.storage.blob.aio import BlobClient
from .._shared.base_client_async import AsyncStorageAccountHostsMixin
from .._path_client import PathClient as PathClientBase
from .._models import DirectoryProperties, AccessControlChangeResult, AccessControlChangeFailure, \
AccessControlChangeCounters, AccessControlChanges
AccessControlChangeCounters, AccessControlChanges, DataLakeAclChangeFailedError
from .._generated.aio import DataLakeStorageClient
from ._data_lake_lease_async import DataLakeLeaseClient
from .._generated.models import StorageErrorException
Expand Down Expand Up @@ -474,8 +475,8 @@ async def _set_access_control_internal(self, options, progress_hook, max_batches
failure_count=total_failure_count),
continuation=last_continuation_token
if total_failure_count > 0 and not continue_on_failure else current_continuation_token)
except StorageErrorException as error:
process_storage_error(error)
except AzureError as error:
raise DataLakeAclChangeFailedError(error, error.message, last_continuation_token)

async def _rename_path(self, rename_source,
**kwargs):
Expand Down

0 comments on commit afcfc3e

Please sign in to comment.