]> git.ipfire.org Git - pbs.git/commitdiff
repos: Whenever a repo is changed we update in the background
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 23 May 2023 15:59:36 +0000 (15:59 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 23 May 2023 15:59:36 +0000 (15:59 +0000)
When a build finishes, it might take too long for the build service to
respond as there might be large repository updates and lots of
dependency checks following.

In order to avoid this breaking builds, we will update in the background
and hopefully afterwards everything will be working better.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/builds.py
src/buildservice/repository.py
src/buildservice/sources.py
src/web/builds.py

index 401c8e5033c6d06c122043d6e9f97eba8bc3cbd1..faae08cc2aeba34b0d030713d8da2764076804eb 100644 (file)
@@ -177,7 +177,7 @@ class Builds(base.Object):
                return list(builds)
 
        async def create(self, repo, package, owner=None, group=None, test=False,
-                       disable_test_builds=False, update=True):
+                       disable_test_builds=False):
                """
                        Creates a new build based on the given distribution and package
                """
@@ -225,7 +225,7 @@ class Builds(base.Object):
                        build._add_watchers()
 
                        # Add the build into its repository
-                       await repo.add_build(build, user=owner, update=update)
+                       await repo.add_build(build, user=owner)
 
                return build
 
@@ -775,9 +775,8 @@ class Build(base.DataObject):
                """
                        This method should be called if the repositories should be updated
                """
-               await asyncio.gather(
-                       *(repo.update() for repo in self.repos),
-               )
+               for repo in self.repos:
+                       await repo.has_changed()
 
        ## Bugs
 
index 88a118322be2bfb80bdc4d160c7625d19f6243b5..3ab217d75c9e365635ec18ec6ce0056aa12aee84 100644 (file)
@@ -420,7 +420,7 @@ class Repository(base.DataObject):
 
        # Add/Remove Builds
 
-       async def add_build(self, build, user=None, update=True):
+       async def add_build(self, build, user=None):
                """
                        Adds a build to this repository
                """
@@ -442,11 +442,10 @@ class Repository(base.DataObject):
                # Update bug status
                # XXX TODO
 
-               # Update the repository
-               if update:
-                       await self.update()
+               # Update the repository (in the background)
+               await self.has_changed()
 
-       async def remove_build(self, build, user=None, update=True):
+       async def remove_build(self, build, user=None):
                """
                        Removes a build from this repository
                """
@@ -469,9 +468,8 @@ class Repository(base.DataObject):
                except IndexError:
                        pass
 
-               # Update the repository
-               if update:
-                       await self.update()
+               # Update the repository (in the background)
+               await self.has_changed()
 
        # Sources
 
index d2469e44c0fc139af04f189b4517b4b21f26b35d..8c28e618e0fd12075be6d91cf44e9381d23bad84 100644 (file)
@@ -811,7 +811,7 @@ class Job(base.DataObject):
 
                        # Create a new build (without updating the repository immediately)
                        build = await self.backend.builds.create(
-                               self.source.repo, package, group=self.commit.builds, update=False)
+                               self.source.repo, package, group=self.commit.builds)
 
                        # XXX add watchers
 
index a8a60ba5aeea6643c68ee3f183199e98639e1914..f805893858249fbbacf6c21af4f2ae7483c9711a 100644 (file)
@@ -293,10 +293,7 @@ class ReposAddHandler(base.BaseHandler):
 
                # Add the build to the repository
                with self.db.transaction():
-                       await repo.add_build(build, user=self.current_user, update=False)
-
-               # Update the repository in the background
-               self.backend.run_task(repo.update)
+                       await repo.add_build(build, user=self.current_user)
 
                self.redirect("/builds/%s" % build.uuid)
 
@@ -333,11 +330,7 @@ class ReposRemoveHandler(base.BaseHandler):
                # Remove build from all repositories
                with self.db.transaction():
                        for repo in repos:
-                               await repo.remove_build(build, user=self.current_user, update=False)
-
-               # Update all repositories in the background
-               for repo in repos:
-                       self.backend.run_task(repo.update)
+                               await repo.remove_build(build, user=self.current_user)
 
                self.redirect("/builds/%s" % build.uuid)