-
Notifications
You must be signed in to change notification settings - Fork 21
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
Duffy client should handle HTTP errors gracefully #525
Comments
mrc0mmand
changed the title
Duffy should handle HTTP errors gracefully
Duffy client should handle HTTP errors gracefully
Aug 5, 2022
This should maybe also get handled somewhat more gracefully: 2022-08-09 05:29:53,328 [agent-control/allocate_node] INFO: Attempting to allocate a node from pool virt-one-medium-centos-8s-ppc64le
2022-08-09 05:29:58,349 [agent-control/main] ERROR: Execution failed
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/httpcore/_exceptions.py", line 8, in map_exceptions
yield
File "/usr/local/lib/python3.8/site-packages/httpcore/backends/sync.py", line 26, in read
return self._sock.recv(max_bytes)
File "/usr/lib64/python3.8/ssl.py", line 1226, in recv
return self.read(buflen)
File "/usr/lib64/python3.8/ssl.py", line 1101, in read
return self._sslobj.read(len)
socket.timeout: The read operation timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/httpx/_transports/default.py", line 60, in map_httpcore_exceptions
yield
File "/usr/local/lib/python3.8/site-packages/httpx/_transports/default.py", line 218, in handle_request
resp = self._pool.handle_request(req)
File "/usr/local/lib/python3.8/site-packages/httpcore/_sync/connection_pool.py", line 253, in handle_request
raise exc
File "/usr/local/lib/python3.8/site-packages/httpcore/_sync/connection_pool.py", line 237, in handle_request
response = connection.handle_request(request)
File "/usr/local/lib/python3.8/site-packages/httpcore/_sync/connection.py", line 90, in handle_request
return self._connection.handle_request(request)
File "/usr/local/lib/python3.8/site-packages/httpcore/_sync/http11.py", line 105, in handle_request
raise exc
File "/usr/local/lib/python3.8/site-packages/httpcore/_sync/http11.py", line 84, in handle_request
) = self._receive_response_headers(**kwargs)
File "/usr/local/lib/python3.8/site-packages/httpcore/_sync/http11.py", line 148, in _receive_response_headers
event = self._receive_event(timeout=timeout)
File "/usr/local/lib/python3.8/site-packages/httpcore/_sync/http11.py", line 177, in _receive_event
data = self._network_stream.read(
File "/usr/local/lib/python3.8/site-packages/httpcore/backends/sync.py", line 26, in read
return self._sock.recv(max_bytes)
File "/usr/lib64/python3.8/contextlib.py", line 131, in __exit__
self.gen.throw(type, value, traceback)
File "/usr/local/lib/python3.8/site-packages/httpcore/_exceptions.py", line 12, in map_exceptions
raise to_exc(exc)
httpcore.ReadTimeout: The read operation timed out
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "./agent-control.py", line 330, in main
ac.allocate_node(args.pool)
File "./agent-control.py", line 69, in allocate_node
result = self._client.request_session([payload])
File "/usr/local/lib/python3.8/site-packages/duffy/client/main.py", line 123, in request_session
return self._query_method(
File "/usr/local/lib/python3.8/site-packages/duffy/client/main.py", line 94, in _query_method
response = client_method(url=url, **add_kwargs)
File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1130, in post
return self.request(
File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 815, in request
return self.send(request, auth=auth, follow_redirects=follow_redirects)
File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 902, in send
response = self._send_handling_auth(
File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 930, in _send_handling_auth
response = self._send_handling_redirects(
File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 967, in _send_handling_redirects
response = self._send_single_request(request)
File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1003, in _send_single_request
response = transport.handle_request(request)
File "/usr/local/lib/python3.8/site-packages/httpx/_transports/default.py", line 218, in handle_request
resp = self._pool.handle_request(req)
File "/usr/lib64/python3.8/contextlib.py", line 131, in __exit__
self.gen.throw(type, value, traceback)
File "/usr/local/lib/python3.8/site-packages/httpx/_transports/default.py", line 77, in map_httpcore_exceptions
raise mapped_exc(message) from exc
httpx.ReadTimeout: The read operation timed out |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is somewhat related to #523, as it causes this issue to pop up quite often, but the duffy client should handle non-successful HTTP codes instead of throwing exceptions around, to make it consistent with the rest of the
DuffyAPIErrorModel
:Ideally it should fill the
DuffyAPIErrorModel
with the HTTP status error details and pass it down as usual, to make error handling consistent.The text was updated successfully, but these errors were encountered: