Skip to content

Commit

Permalink
[autoscaler] Fix Error Handling for botocore (ray-project#3534)
Browse files Browse the repository at this point in the history
Unfortunately Boto generates error classes dynamically, so this catches
the expected error and raises the error if it is the wrong class.

Closes ray-project#3533.
  • Loading branch information
richardliaw authored Dec 14, 2018
1 parent 2a4685a commit de3fdeb
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions python/ray/autoscaler/aws/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,11 @@ def _get_role(role_name, config):
try:
role.load()
return role
except botocore.errorfactory.NoSuchEntityException:
return None
except botocore.exceptions.ClientError as exc:
if exc.response.get("Error", {}).get("Code") == "NoSuchEntity":
return None
else:
raise exc


def _get_instance_profile(profile_name, config):
Expand All @@ -283,8 +286,11 @@ def _get_instance_profile(profile_name, config):
try:
profile.load()
return profile
except botocore.errorfactory.NoSuchEntityException:
return None
except botocore.exceptions.ClientError as exc:
if exc.response.get("Error", {}).get("Code") == "NoSuchEntity":
return None
else:
raise exc


def _get_key(key_name, config):
Expand Down

0 comments on commit de3fdeb

Please sign in to comment.