From 1a16a099a2519ea6d947d729d7c72f4917f2d55d Mon Sep 17 00:00:00 2001 From: Hugo Herter Date: Mon, 4 Jul 2022 18:55:28 +0200 Subject: [PATCH] Fix: Could not save multiple execution records for the same execution --- vm_supervisor/metrics.py | 2 ++ vm_supervisor/models.py | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/vm_supervisor/metrics.py b/vm_supervisor/metrics.py index db9dbab4a..80ab2f9ee 100644 --- a/vm_supervisor/metrics.py +++ b/vm_supervisor/metrics.py @@ -34,6 +34,8 @@ class ExecutionRecord(Base): __tablename__ = "records" uuid = Column(String, primary_key=True) + + execution_uuid = Column(String, nullable=False) vm_hash = Column(String, nullable=False) time_defined = Column(DateTime, nullable=False) diff --git a/vm_supervisor/models.py b/vm_supervisor/models.py index 75070b7dc..0d211db48 100644 --- a/vm_supervisor/models.py +++ b/vm_supervisor/models.py @@ -205,7 +205,8 @@ async def record_usage(self): if pid_info and pid_info.get("process"): await save_record( ExecutionRecord( - uuid=str(self.uuid), + uuid=str(uuid.uuid4()), + execution_uuid=str(self.uuid), vm_hash=self.vm_hash, time_defined=self.times.defined_at, time_prepared=self.times.prepared_at, @@ -227,7 +228,8 @@ async def record_usage(self): # and its metrics are not available anymore. await save_record( ExecutionRecord( - uuid=str(self.uuid), + uuid=str(uuid.uuid4()), + execution_uuid=str(self.uuid), vm_hash=self.vm_hash, time_defined=self.times.defined_at, time_prepared=self.times.prepared_at,