From: Michael Tremer Date: Wed, 2 Aug 2023 17:17:36 +0000 (+0000) Subject: jobs: Launch installcheck in transactions and wait for it X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d2537589879aa0d3c3591fd45343c3afda892d08;p=pbs.git jobs: Launch installcheck in transactions and wait for it It can happen that a transaction is being rolled back and an installcheck has been queued which will then run into errors. Since the installcheck is now fast enough, we can simply wait for it with the exception of relaunching any pending jobs in repositories which will be run as one single task in the background. Signed-off-by: Michael Tremer --- diff --git a/src/buildservice/jobs.py b/src/buildservice/jobs.py index 5dbe8538..87800ad9 100644 --- a/src/buildservice/jobs.py +++ b/src/buildservice/jobs.py @@ -173,14 +173,8 @@ class Jobs(base.Object): repos = misc.group(jobs, lambda job: job.build.build_repo) # Run the dependency check for each repository concurrently - async with asyncio.TaskGroup() as tasks: - for repo in repos: - tasks.create_task( - repo.installcheck(repos[repo]) - ) - - # Dispatch any jobs - await self.backend.jobs.queue.dispatch() + for repo in repos: + await repo.installcheck(repos[repo]) class Queue(base.Object): diff --git a/src/buildservice/releasemonitoring.py b/src/buildservice/releasemonitoring.py index 44987ff9..6306fa03 100644 --- a/src/buildservice/releasemonitoring.py +++ b/src/buildservice/releasemonitoring.py @@ -332,9 +332,8 @@ class Monitoring(base.DataObject): except BuildExistsError as e: log.debug("Latest build is newer") - # Launch the build - if release and release.build: - await self.backend.builds.launch([release.build]) + # Dispatch any jobs + await self.backend.jobs.queue.dispatch() async def _fetch_versions(self): """ @@ -753,6 +752,9 @@ class Release(base.DataObject): self.build = build self.repo = repo + # Launch the build + await self.backend.builds.launch([build]) + async def _update_source_package(self, package, target): """ Takes a package and recreates it with this release diff --git a/src/web/jobs.py b/src/web/jobs.py index 813532ab..598c366b 100644 --- a/src/web/jobs.py +++ b/src/web/jobs.py @@ -245,8 +245,8 @@ class RetryHandler(base.BaseHandler): with self.db.transaction(): job = await job.retry(self.current_user) - # Launch the newly created job - await self.backend.jobs.launch([job]) + # Launch the newly created job + await self.backend.jobs.launch([job]) # Redirect back to the build page self.redirect("/builds/%s" % job.build.uuid)