From 80329078bbc55ced0de7eec3f674fd5c7fdd073d Mon Sep 17 00:00:00 2001 From: Hugo Herter Date: Sun, 8 May 2022 11:30:39 +0200 Subject: [PATCH] Fix: AttributeError crashed VM teardown During VM teardown, the field AlephFirecrackerVM().guest_api_process._popen could be None, and the following traceback be raised: ```python File "/root/aleph-vm/vm_supervisor/models.py", line 116, in create await vm.teardown() File "/root/aleph-vm/vm_supervisor/vm/firecracker_microvm.py", line 429, in teardown await self.stop_guest_api() File "/root/aleph-vm/vm_supervisor/vm/firecracker_microvm.py", line 424, in stop_guest_api self.guest_api_process.terminate() File "/usr/lib/python3.8/multiprocessing/process.py", line 133, in terminate self._popen.terminate() AttributeError: 'NoneType' object has no attribute 'terminate' ``` --- vm_supervisor/vm/firecracker_microvm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vm_supervisor/vm/firecracker_microvm.py b/vm_supervisor/vm/firecracker_microvm.py index 105d680a6..ba9e90c7e 100644 --- a/vm_supervisor/vm/firecracker_microvm.py +++ b/vm_supervisor/vm/firecracker_microvm.py @@ -420,7 +420,7 @@ async def start_guest_api(self): logger.debug(f"started guest API for {self.vm_id}") async def stop_guest_api(self): - if self.guest_api_process: + if self.guest_api_process and self.guest_api_process._popen: self.guest_api_process.terminate() async def teardown(self):