aleph-im / aleph-vm

Aleph.im VM execution engine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Traceback `FileNotFoundError` unix socket

hoh opened this issue · comments

Serving on (4294967295, 52)                                                                                                                   
unhandled exception during asyncio.run() shutdown                                                                                             
task: <Task finished name='Task-1' coro=<_run_app() done, defined at /usr/lib/python3/dist-packages/aiohttp/web.py:289> exception=FileNotFound
Error(2, 'No such file or directory')>                                                                                                        
Traceback (most recent call last):                                                                                                            
  File "/usr/lib/python3/dist-packages/aiohttp/web.py", line 516, in run_app                                                                  
    loop.run_until_complete(main_task)                                                                                                        
  File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete                                                          
    return future.result()                                                                                                                    
           ^^^^^^^^^^^^^^^                                                                                                                    
  File "/usr/lib/python3/dist-packages/aiohttp/web.py", line 415, in _run_app                                                                 
    await site.start()                                                                                                                        
  File "/usr/lib/python3/dist-packages/aiohttp/web_runner.py", line 162, in start                                                             
    self._server = await loop.create_unix_server(                                                                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                             
  File "/usr/lib/python3.11/asyncio/unix_events.py", line 317, in create_unix_server                                                          
    sock.bind(path)                                                                                                                           
FileNotFoundError: [Errno 2] No such file or directory                                                                                        
Process Process-3:                                                                                                                            
Traceback (most recent call last):                                                                                                            
  File "/usr/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap                                                              
    self.run()                                                                                                                                
  File "/usr/lib/python3.11/multiprocessing/process.py", line 108, in run                                                                     
    self._target(*self._args, **self._kwargs)                                                                                                 
  File "/root/aleph-vm/guest_api/__main__.py", line 181, in run_guest_api                                                                     
    web.run_app(app=app, path=unix_socket_path)                                                                                               
  File "/usr/lib/python3/dist-packages/aiohttp/web.py", line 516, in run_app                                                                  
    loop.run_until_complete(main_task)                                 
  File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete                                                          
    return future.result()                                             
           ^^^^^^^^^^^^^^^                                             
  File "/usr/lib/python3/dist-packages/aiohttp/web.py", line 415, in _run_app                                                                 
    await site.start()                                                 
  File "/usr/lib/python3/dist-packages/aiohttp/web_runner.py", line 162, in start                                                             
    self._server = await loop.create_unix_server(                                                                                             
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                             
  File "/usr/lib/python3.11/asyncio/unix_events.py", line 317, in create_unix_server                                                          
    sock.bind(path)                                                    
FileNotFoundError: [Errno 2] No such file or directory   

Code:

diff --git a/vm_supervisor/supervisor.py b/vm_supervisor/supervisor.py
index 9a95dec..f391931 100644
--- a/vm_supervisor/supervisor.py
+++ b/vm_supervisor/supervisor.py
@@ -96,6 +96,15 @@ def run():
             app.on_cleanup.append(stop_all_vms)
 
         web.run_app(app, host=settings.SUPERVISOR_HOST, port=settings.SUPERVISOR_PORT)
+    except OSError as e:
+        if e.errno == 98:
+            logger.error(
+                f"Port {settings.SUPERVISOR_PORT} already in use. "
+                f"Please check that no other instance of Aleph-VM is running.",
+                exc_info=False,
+            )
+        else:
+            raise
     finally:
         if settings.ALLOW_VM_NETWORKING:
             pool.network.teardown()
root@aleph-vm-lab-2 ~/aleph-vm (main)# git log
commit 9117b016131f8544963d857e69897da2128e5ae5 (HEAD -> main, origin/main)

Not reported on Sentry ?

Similar issue on aleph.sh version 2.8:

Oct 05 13:38:36 aleph-sh python3[53604]: Traceback (most recent call last):
Oct 05 13:38:36 aleph-sh python3[53604]:   File "/usr/lib/python3/dist-packages/aiohttp/web_protocol.py", line 435, in _handle_request
Oct 05 13:38:36 aleph-sh python3[53604]:     resp = await request_handler(request)
Oct 05 13:38:36 aleph-sh python3[53604]:   File "/usr/lib/python3/dist-packages/aiohttp/web_app.py", line 504, in _handle
Oct 05 13:38:36 aleph-sh python3[53604]:     resp = await handler(request)
Oct 05 13:38:36 aleph-sh python3[53604]:   File "/usr/lib/python3/dist-packages/aiohttp/web_middlewares.py", line 117, in impl
Oct 05 13:38:36 aleph-sh python3[53604]:     return await handler(request)
Oct 05 13:38:36 aleph-sh python3[53604]:   File "/opt/aleph-vm/vm_supervisor/supervisor.py", line 41, in server_version_middleware
Oct 05 13:38:36 aleph-sh python3[53604]:     resp: web.StreamResponse = await handler(request)
Oct 05 13:38:36 aleph-sh python3[53604]:   File "/usr/lib/python3/dist-packages/aiohttp/web_urldispatcher.py", line 197, in handler_wrapper
Oct 05 13:38:36 aleph-sh python3[53604]:     return await result
Oct 05 13:38:36 aleph-sh python3[53604]:   File "/opt/aleph-vm/vm_supervisor/run.py", line 97, in run_code_on_request
Oct 05 13:38:36 aleph-sh python3[53604]:     result_raw: bytes = await execution.run_code(scope=scope)
Oct 05 13:38:36 aleph-sh python3[53604]:   File "/opt/aleph-vm/vm_supervisor/models.py", line 267, in run_code
Oct 05 13:38:36 aleph-sh python3[53604]:     return await self.vm.run_code(scope=scope)
Oct 05 13:38:36 aleph-sh python3[53604]:   File "/opt/aleph-vm/vm_supervisor/vm/firecracker_microvm.py", line 471, in run_code
Oct 05 13:38:36 aleph-sh python3[53604]:     reader, writer = await asyncio.open_unix_connection(
Oct 05 13:38:36 aleph-sh python3[53604]:   File "/usr/lib/python3.10/asyncio/streams.py", line 98, in open_unix_connection
Oct 05 13:38:36 aleph-sh python3[53604]:     transport, _ = await loop.create_unix_connection(
Oct 05 13:38:36 aleph-sh python3[53604]:   File "/usr/lib/python3.10/asyncio/unix_events.py", line 255, in create_unix_connection
Oct 05 13:38:36 aleph-sh python3[53604]:     await self.sock_connect(sock, path)
Oct 05 13:38:36 aleph-sh python3[53604]:   File "/usr/lib/python3.10/asyncio/selector_events.py", line 501, in sock_connect
Oct 05 13:38:36 aleph-sh python3[53604]:     return await fut
Oct 05 13:38:36 aleph-sh python3[53604]:   File "/usr/lib/python3.10/asyncio/selector_events.py", line 509, in _sock_connect
Oct 05 13:38:36 aleph-sh python3[53604]:     sock.connect(address)
Oct 05 13:38:36 aleph-sh python3[53604]: FileNotFoundError: [Errno 2] No such file or directory