]> git.ipfire.org Git - pbs.git/commitdiff
jobs: Perform installcheck before a job is being dispatched
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 25 Jul 2023 14:08:57 +0000 (14:08 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 25 Jul 2023 14:08:57 +0000 (14:08 +0000)
I would like to perform fewer of the installchecks because they unlikely
to fail and rather expensive to run.

This is a safety net so that we will never dispatch any jobs that cannot
be built.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/jobs.py

index 52736240e6890eb3cdff300b4bdceb4734c1b636..d0bb3a2cc0ab9adf09658f00ec0c588e8acce5fd 100644 (file)
@@ -178,11 +178,11 @@ class Queue(base.Object):
 
                return list(jobs)
 
-       def pop(self, builder):
+       def get_jobs_for_builder(self, builder, limit=None):
                """
-                       Returns the next build job that matches the given architectures
+                       Returns all jobs that the given builder can process.
                """
-               return self.backend.jobs._get_job("""
+               return self.backend.jobs._get_jobs("""
                        %s
 
                        SELECT
@@ -191,7 +191,6 @@ class Queue(base.Object):
                                job_queue
                        WHERE
                                job_queue.arch = ANY(%%s)
-                       LIMIT 1
                        """ % JOB_QUEUE_CTE, builder.supported_arches,
                )
 
@@ -237,17 +236,19 @@ class Queue(base.Object):
                                log.debug("  Processing builder %s" % builder)
 
                                with self.backend.db.transaction():
-                                       # We are ready for a new job
-                                       job = self.pop(builder)
+                                       try:
+                                               # We are ready for a new job
+                                               for job in self.get_jobs_for_builder(builder):
+                                                       # Perform installcheck (just to be sure)
+                                                       if not await job.installcheck():
+                                                               log.debug("Job %s failed its installcheck" % job)
+                                                               continue
 
-                                       # If no job could be found for this builder, we simply continue
-                                       if not job:
-                                               log.debug("  No jobs processable for %s" % builder)
-                                               continue
+                                                       # If we have a job, we dispatch it to the builder
+                                                       builder.dispatch_job(job)
 
-                                       # If we have a job, we dispatch it to the builder
-                                       try:
-                                               builder.dispatch_job(job)
+                                                       # Once we dispatched a job, we are done
+                                                       break
 
                                        # Ignore if the builder suddenly went away
                                        except BuilderNotOnlineError:
@@ -920,6 +921,9 @@ class Job(base.DataObject):
                """
                await self.build.build_repo.installcheck([self])
 
+               # Return whether the check succeeded or not
+               return self.installcheck_succeeded
+
        async def _installcheck(self, p):
                """
                        Implementation that takes an active Pakfire instance and