From: Michael Tremer Date: Thu, 6 Feb 2025 16:27:17 +0000 (+0000) Subject: jobs: Fix finishing jobs X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=37e6951145f6b85198157ab3da9811a5158a3ff1;p=pbs.git jobs: Fix finishing jobs Obviously the database field is nullable and NULL by default. Signed-off-by: Michael Tremer --- diff --git a/src/buildservice/jobs.py b/src/buildservice/jobs.py index 71e07ccf..eb64a4f4 100644 --- a/src/buildservice/jobs.py +++ b/src/buildservice/jobs.py @@ -611,7 +611,7 @@ class Job(database.Base, database.BackendMixin, database.SoftDeleteMixin): # Finished At - finished_at = Column(DateTime(timezone=False), nullable=False) + finished_at = Column(DateTime(timezone=False)) # Date @@ -777,15 +777,16 @@ class Job(database.Base, database.BackendMixin, database.SoftDeleteMixin): return self.started_at and not self.finished_at and not self.aborted_at def has_finished(self): - # Jobs can be marked as finished - if self.finished_at: - return True - - # Jobs can be marked as aborted, too - elif self.aborted_at: - return True + """ + Returns True if this job has finished, been aborted, etc. + """ + # This check is checking if finished_at is set because SQLAlchemy is behaving + # a little bit stupid when we set finished_at to sqlalchemy.func.current_timestamp() + # because since this is a server function, it cannot know the value before we commit. + if self.finished_at is None: + return False - return False + return True # Failed