Skip to content

Commit fd058fb

Browse files
smtakedaankit-bhatnagar167
authored andcommitted
SNOW-74395: Fixed Azure token renewal with long running jobs
1 parent 5be6b8c commit fd058fb

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

azure_util.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,12 @@ def get_file_header(meta, filename):
8989
encryption_metadata=None
9090
)
9191
except AzureHttpError as err:
92-
if (
93-
err.status_code == 403 and "Signature not valid in the specified time frame" in str(
94-
err)):
92+
logger.debug(u"Caught exception's status code: {status_code} and message: {ex_representation}".format(
93+
status_code=err.status_code,
94+
ex_representation=str(err)
95+
))
96+
if err.status_code == 403 and ("Signature not valid in the specified time frame" in str(err) or
97+
"Server failed to authenticate the request." in str(err)):
9598
logger.debug(u"AZURE Token expired. Renew and retry")
9699
meta[u'result_status'] = ResultStatus.RENEW_TOKEN
97100
return None
@@ -183,9 +186,12 @@ def azure_callback(current, total):
183186
meta[u'dst_file_size'] = meta[u'upload_size']
184187
meta[u'result_status'] = ResultStatus.UPLOADED
185188
except AzureHttpError as err:
186-
if (
187-
err.status_code == 403 and "Signature not valid in the specified time frame" in str(
188-
err)):
189+
logger.debug(u"Caught exception's status code: {status_code} and message: {ex_representation}".format(
190+
status_code=err.status_code,
191+
ex_representation=str(err)
192+
))
193+
if err.status_code == 403 and ("Signature not valid in the specified time frame" in str(err) or
194+
"Server failed to authenticate the request." in str(err)):
189195
logger.debug(u"AZURE Token expired. Renew and retry")
190196
meta[u'result_status'] = ResultStatus.RENEW_TOKEN
191197
return None
@@ -229,9 +235,12 @@ def azure_callback(current, total):
229235

230236
meta[u'result_status'] = ResultStatus.DOWNLOADED
231237
except AzureHttpError as err:
232-
if (
233-
err.status_code == 403 and "Signature not valid in the specified time frame" in str(
234-
err)):
238+
logger.debug(u"Caught exception's status code: {status_code} and message: {ex_representation}".format(
239+
status_code=err.status_code,
240+
ex_representation=str(err)
241+
))
242+
if (err.status_code == 403 and ("Signature not valid in the specified time frame" in str(err) or
243+
"Server failed to authenticate the request." in str(err))):
235244
logger.debug(u"AZURE Token expired. Renew and retry")
236245
meta[u'result_status'] = ResultStatus.RENEW_TOKEN
237246
return None

0 commit comments

Comments
 (0)