Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled Exception due to Intersection of Request Exception Handling Logic + Exception's __str__ Method #107

Open
jeffwecan opened this issue Mar 30, 2020 · 0 comments
Assignees
Labels

Comments

@jeffwecan
Copy link
Collaborator

#90 combined with #94 in v1.2.0 is leading to unintended behavior during certain classes of failing requests to a given Nomad API address. For example, in this (poorly formatted, sorry!) lambda's traceback:

Traceback (most recent call last):
[...]
raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPConnectionPool(host='10.55.3.155', port=4646): Read timed out. (read timeout=5)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
[...]
File "/var/task/nomad/api/node.py", line 182, in eligible_node
return self.request(id, "eligibility", json=payload, method="post").json()
File "/var/task/nomad/api/base.py", line 77, in request
response = self._request(
File "/var/task/nomad/api/base.py", line 164, in _request
raise nomad.api.exceptions.BaseNomadException(error)
nomad.api.exceptions.BaseNomadException: <exception str() failed>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/var/runtime/bootstrap", line 12, in <module>
main()
File "/var/runtime/bootstrap.py", line 473, in main
handle_event_request(lambda_runtime_client,
File "/var/runtime/bootstrap.py", line 145, in handle_event_request
xray_fault = make_xray_fault(etype.__name__, str(value), os.getcwd(), tb_tuples)
File "/var/task/nomad/api/exceptions.py", line 7, in __str__
return 'The {0} was raised with following response: {1}.'.format(self.__class__.__name__, self.nomad_resp.text)
AttributeError: 'ReadTimeout' object has no attribute 'text'

I'm not sure what is the best way to resolve the matter quite yet, but I'm happy to give it a shot! It seems like the crux of the matter, is that __str__ on BaseNomadException should not be making assumptions about what type of object is receives in its nomad_resp attribute or something similar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants