From: Michael Tremer Date: Tue, 25 Jul 2023 14:08:57 +0000 (+0000) Subject: jobs: Perform installcheck before a job is being dispatched X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1abe4587b6f532b15be65feb5d941c80d33ecd0c;p=pbs.git jobs: Perform installcheck before a job is being dispatched 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 --- diff --git a/src/buildservice/jobs.py b/src/buildservice/jobs.py index 52736240..d0bb3a2c 100644 --- a/src/buildservice/jobs.py +++ b/src/buildservice/jobs.py @@ -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