Skip to content

Commit d5e51e9

Browse files
authored
a couple of small issues in s3 error handling (#821)
1 parent 584b7e1 commit d5e51e9

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

metaflow/datatools/s3op.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def normalize_client_error(err):
8989
try:
9090
return int(error_code)
9191
except ValueError:
92-
if error_code == "AccessDenied":
92+
if error_code in ("AccessDenied", "AllAccessDisabled"):
9393
return 403
9494
if error_code == "NoSuchKey":
9595
return 404
@@ -400,7 +400,7 @@ def list_prefix(self, prefix_url, delimiter=""):
400400
except self.s3.exceptions.NoSuchBucket:
401401
return False, prefix_url, ERROR_URL_NOT_FOUND
402402
except self.client_error as err:
403-
if err.response["Error"]["Code"] == "AccessDenied":
403+
if err.response["Error"]["Code"] in ("AccessDenied", "AllAccessDisabled"):
404404
return False, prefix_url, ERROR_URL_ACCESS_DENIED
405405
else:
406406
raise

metaflow/datatools/s3tail.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ def __init__(self, s3url):
1818
self._pos = 0
1919
self._tail = b""
2020

21+
def reset_client(self, hard_reset=False):
22+
# This method is required by @aws_retry
23+
if hard_reset or self.s3 is None:
24+
self.s3, self.ClientError = get_s3_client()
25+
2126
def clone(self, s3url):
2227
tail = S3Tail(s3url)
2328
tail._pos = self._pos

metaflow/mflog/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,7 @@ def _available_logs(tail, stream, echo, should_persist=False):
119119
echo(line.strip().decode("utf-8", errors="replace"), stream)
120120
except Exception as ex:
121121
echo(
122-
"%s[ temporary error in fetching logs: %s ]" % to_unicode(prefix),
123-
ex,
122+
"%s[ temporary error in fetching logs: %s ]" % (to_unicode(prefix), ex),
124123
"stderr",
125124
)
126125

0 commit comments

Comments
 (0)