Skip to content

Conversation

@herheliuk
Copy link
Member

[Errno 2] No such file or directory -> Socket file not found.
[Errno 111] Connection refused -> Service not running.

Signed-off-by: Andrii Herheliuk [email protected]

[Errno 2] No such file or directory -> Socket file not found.
[Errno 111] Connection refused -> Service not running.

Signed-off-by: Andrii Herheliuk <[email protected]>
@herheliuk herheliuk changed the title pycriu: better socket error handling pycriu: better socket error handling Oct 23, 2025
@avagin avagin requested a review from Copilot October 23, 2025 21:03
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR improves error handling for socket connection failures in the CRIU Python library by catching and re-raising specific socket exceptions with more user-friendly error messages.

Key Changes:

  • Added try-except block around socket connection logic
  • Added FileNotFoundError handling for missing socket files
  • Added ConnectionRefusedError handling for service unavailability

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@herheliuk
Copy link
Member Author

herheliuk commented Oct 23, 2025

@avagin do you want me to change that?

pycriu.criu.CRIUExceptionInternal: DUMP failed with internal error: Service not running.

I think it's a bit too long already (in a traceback)

pycriu.criu.CRIUExceptionInternal: DUMP failed with internal error: Service not running: criu_service.socket

And people can easily handle that themselves with try/except if they want to.

@herheliuk
Copy link
Member Author

herheliuk commented Oct 23, 2025

Copilot said: The error message loses the original socket path information.

There is no path information there, and the original error is still in the stack trace.

Traceback (most recent call last):
  File "/home/user/criu_api/env/lib/python3.12/site-packages/pycriu/criu.py", line 49, in connect
    self.sk.connect(self.comm)
FileNotFoundError: [Errno 2] No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/criu_api/env/lib/python3.12/site-packages/pycriu/criu.py", line 252, in _send_req_and_recv_resp
    s = self._comm.connect(daemon)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/criu_api/env/lib/python3.12/site-packages/pycriu/criu.py", line 52, in connect
    raise FileNotFoundError("Socket file not found.")
FileNotFoundError: Socket file not found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/criu_api/test.py", line 16, in <module>
    criu.dump()
  File "/home/user/criu_api/env/lib/python3.12/site-packages/pycriu/criu.py", line 293, in dump
    resp = self._send_req_and_recv_resp(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/criu_api/env/lib/python3.12/site-packages/pycriu/criu.py", line 269, in _send_req_and_recv_resp
    raise CRIUExceptionInternal(req.type, str(e))
pycriu.criu.CRIUExceptionInternal: DUMP failed with internal error: Socket file not found.

@avagin avagin merged commit ae971c9 into checkpoint-restore:criu-dev Oct 27, 2025
40 of 45 checks passed
@herheliuk herheliuk deleted the pycriu-socket-errors branch October 27, 2025 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants