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

catch ConnectionResetError in kr8s._portforward.PortForward._tcp_to_ws #539

Closed
filip-taxamo opened this issue Jan 2, 2025 · 0 comments · Fixed by #541
Closed

catch ConnectionResetError in kr8s._portforward.PortForward._tcp_to_ws #539

filip-taxamo opened this issue Jan 2, 2025 · 0 comments · Fixed by #541
Labels
bug Something isn't working

Comments

@filip-taxamo
Copy link

Which project are you reporting a bug for?

kr8s

What happened?

Hello,

when using kr8s.objects.Pod().portforward to reach PostgreSQL with psycopg, we are getting the following at the end of a successful communication with the PostgreSQL server:

Unhandled exception in client_connected_cb
transport: <_SelectorSocketTransport closed fd=11>
  + Exception Group Traceback (most recent call last):
  |   File "/app/lib/python3.13/site-packages/kr8s/_portforward.py", line 238, in _sync_sockets
  |     with suppress(ConnectionClosedError, httpx_ws.WebSocketDisconnect):
  |          ~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |   File "/usr/local/lib/python3.13/contextlib.py", line 468, in __exit__
  |     raise rest
  |   File "/app/lib/python3.13/site-packages/kr8s/_portforward.py", line 239, in _sync_sockets
  |     async with anyio.create_task_group() as tg:
  |                ~~~~~~~~~~~~~~~~~~~~~~~^^
  |   File "/app/lib/python3.13/site-packages/anyio/_backends/_asyncio.py", line 815, in __aexit__
  |     raise BaseExceptionGroup(
  |         "unhandled errors in a TaskGroup", self._exceptions
  |     )
  | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
  +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    |   File "/app/lib/python3.13/site-packages/kr8s/_portforward.py", line 247, in _tcp_to_ws
    |     data = await reader.read(1024 * 1024)
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |   File "/usr/local/lib/python3.13/asyncio/streams.py", line 730, in read
    |     await self._wait_for_data('read')
    |   File "/usr/local/lib/python3.13/asyncio/streams.py", line 539, in _wait_for_data
    |     await self._waiter
    |   File "/usr/local/lib/python3.13/asyncio/selector_events.py", line 1005, in _read_ready__data_received
    |     data = self._sock.recv(self.max_size)
    | ConnectionResetError: [Errno 104] Connection reset by peer
    +------------------------------------

Should ConnectionResetError be added to the exceptions @ https://github.com/kr8s-org/kr8s/blob/v0.18.1/kr8s/_portforward.py#L238 or handled for https://github.com/kr8s-org/kr8s/blob/v0.18.1/kr8s/_portforward.py#L247 like it is present for sending @ https://github.com/kr8s-org/kr8s/blob/v0.18.1/kr8s/_portforward.py#L255 ?

Anything else?

No response

@filip-taxamo filip-taxamo added the bug Something isn't working label Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant