Skip to content

Commit 4aa3eb8

Browse files
committed
Fix inconsistant execution state
this was occasionally causing crash when trying a second launch
1 parent f59cc5f commit 4aa3eb8

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/aleph/vm/pool.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ async def load_persistent_executions(self):
241241
if await self.systemd_manager.is_service_active(
242242
execution.controller_service
243243
): # TODO: Improve the way that we re-create running execution
244+
logger.debug(("Execution %s is still running in systemd, reconnecting", execution.vm_hash))
244245
await execution.prepare()
245246
if self.network:
246247
vm_type = VmType.from_message_content(execution.message)
@@ -251,16 +252,21 @@ async def load_persistent_executions(self):
251252
vm = execution.create(vm_id=vm_id, tap_interface=tap_interface, prepare=False)
252253
await vm.start_guest_api()
253254
execution.ready_event.set()
255+
execution.times.starting_at = execution.times.starting_at or datetime.now(tz=timezone.utc)
254256
execution.times.started_at = datetime.now(tz=timezone.utc)
255-
257+
execution.times.stopping_at = None
258+
execution.times.stopped_at = None
256259
self._schedule_forget_on_stop(execution)
257260

258261
# Start the snapshot manager for the VM
259262
if vm.support_snapshot and self.snapshot_manager:
260263
await self.snapshot_manager.start_for(vm=execution.vm)
261264

265+
assert execution.is_running
262266
self.executions[vm_hash] = execution
267+
263268
else:
269+
logger.debug(("Execution %s is not running in systemd, reconnecting", execution.vm_hash))
264270
execution.uuid = saved_execution.uuid
265271
await execution.record_usage()
266272

0 commit comments

Comments
 (0)