From e7c8ff9ae4d31bb71c5324cf1c4572767cb706b3 Mon Sep 17 00:00:00 2001 From: dshylov Date: Fri, 10 Apr 2020 16:24:56 +0300 Subject: [PATCH 1/2] MAPRDB-2230 OJAI Python Client query fails with STATUS TOKEN EXPIRED --- mapr/ojai/storage/OJAIConnection.py | 2 +- mapr/ojai/storage/auth_interceptor.py | 1 + mapr/ojai/utils/retry_utils.py | 7 ++++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/mapr/ojai/storage/OJAIConnection.py b/mapr/ojai/storage/OJAIConnection.py index a0bb78d..cf56be3 100644 --- a/mapr/ojai/storage/OJAIConnection.py +++ b/mapr/ojai/storage/OJAIConnection.py @@ -176,7 +176,7 @@ def is_store_exists(self, store_path): elif response.error.err_code == ErrorCode.Value('TABLE_NOT_FOUND'): return False else: - raise UnknownServerError + raise UnknownServerError(m=response.error.error_message) def delete_store(self, store_path): self.__validate_store_path(store_path=store_path) diff --git a/mapr/ojai/storage/auth_interceptor.py b/mapr/ojai/storage/auth_interceptor.py index f49b79e..8a9a68d 100644 --- a/mapr/ojai/storage/auth_interceptor.py +++ b/mapr/ojai/storage/auth_interceptor.py @@ -49,6 +49,7 @@ def metadata_builder(self): value = 'basic {0}'.format(self._encoded_user_creds) else: value = 'bearer {0}'.format(self._token) + self._token = None return 'authorization', value def set_jwt_token(self, call, stream=False): diff --git a/mapr/ojai/utils/retry_utils.py b/mapr/ojai/utils/retry_utils.py index b2d868d..f497fb5 100644 --- a/mapr/ojai/utils/retry_utils.py +++ b/mapr/ojai/utils/retry_utils.py @@ -31,7 +31,12 @@ def __init__(self, # Retry checker function def retry_if_connection_not_established(exception): if isinstance(exception, _Rendezvous): - return exception.code() == StatusCode.UNAVAILABLE or exception.code() == StatusCode.RESOURCE_EXHAUSTED + if exception.code() == StatusCode.UNAUTHENTICATED \ + and exception.details() == 'STATUS_TOKEN_EXPIRED': + return True + else: + return exception.code() == StatusCode.UNAVAILABLE \ + or exception.code() == StatusCode.RESOURCE_EXHAUSTED elif isinstance(exception, ExpiredTokenError): return True else: From c0f096cbefebbaf3dd919c921b6c1dd885906c7e Mon Sep 17 00:00:00 2001 From: dshylov Date: Tue, 21 Apr 2020 11:54:02 +0300 Subject: [PATCH 2/2] update to 1.1.3 version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 5333722..088502e 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup(name='maprdb_python_client', - version='1.1.2', + version='1.1.3', description='MapR-DB Python Client', url='https://github.com/mapr/maprdb-python-client/', author='MapR, Inc.',