Skip to content

Commit

Permalink
Solve Firecracker reboot issues (#658)
Browse files Browse the repository at this point in the history
Problem: If the frontend or a user send the request to reboot a Firecracker instance, it stops but doesn't start again.

Solution: Change method to restart it just stopping the process, cleaning the firecracker run files and starting it again.
  • Loading branch information
nesitor authored Jul 23, 2024
1 parent f9cb9b7 commit e47abd6
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/aleph/vm/controllers/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ async def handle_persistent_vm(config: Configuration, execution: Union[MicroVM,

def callback():
"""Callback for the signal handler to stop the VM and cleanup properly on SIGTERM."""
loop.create_task(execution.teardown())
loop.create_task(execution.stop())

loop.add_signal_handler(signal.SIGTERM, callback)

Expand Down
1 change: 1 addition & 0 deletions src/aleph/vm/hypervisors/firecracker/microvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ def prepare_start(self):
system(f"rm -fr {self.jailer_path}/dev/net/")
system(f"rm -fr {self.jailer_path}/dev/kvm")
system(f"rm -fr {self.jailer_path}/dev/urandom")
system(f"rm -fr {self.jailer_path}/dev/userfaultfd")
system(f"rm -fr {self.jailer_path}/run/")

if os.path.exists(path=self.vsock_path):
Expand Down
2 changes: 1 addition & 1 deletion src/aleph/vm/hypervisors/qemu/qemuvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,6 @@ def send_shutdown_message(self):
print("shutdown message sent")
client.close()

async def teardown(self):
async def stop(self):
"""Stop the VM."""
self.send_shutdown_message()

0 comments on commit e47abd6

Please sign in to comment.