From be4d67bfc1eb1e09d01f40f2d0bd8762c0472d4f Mon Sep 17 00:00:00 2001 From: Xavier-Do Date: Tue, 17 Dec 2024 14:06:20 +0100 Subject: [PATCH] wip --- runbot/models/build.py | 12 ++++++++++++ runbot/templates/utils.xml | 11 ++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/runbot/models/build.py b/runbot/models/build.py index 9daa3d731..836b6d817 100644 --- a/runbot/models/build.py +++ b/runbot/models/build.py @@ -238,6 +238,7 @@ class BuildResult(models.Model): commit_export_ids = fields.One2many('runbot.commit.export', 'build_id') static_run = fields.Char('Static run URL') + db_garbage_collected = fields.Boolean() access_token = fields.Char('Token', default=lambda self: uuid.uuid4().hex) @@ -962,6 +963,7 @@ def _get_modules_to_test(self, modules_patterns=''): def _local_pg_dropdb(self, dbname): msg = '' + self._build_from_dest(dbname).db_garbage_collected = True try: with local_pgadmin_cursor() as local_cr: query = 'SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname=%s' @@ -1046,6 +1048,15 @@ def _ask_kill(self, lock=True, message=None): for child in build.children_ids: child._ask_kill(lock=False) + def _can_wake_up(self): + return ( + self.local_state == "done" and + self.requested_action != 'wake_up' and + self.host_id.active and + self.database_ids and + (not self.parent_id.database_ids or self.env.user.has_group('runbot.group_runbot_advanced_user')) + ) + def _wake_up(self): user = self.env.user self._log('wake_up', f'Wake up initiated by {user.name}') @@ -1269,3 +1280,4 @@ def _github_status(self): def _parse_config(self): return set(findall(self._server("tools/config.py"), r'--[\w-]+', )) + diff --git a/runbot/templates/utils.xml b/runbot/templates/utils.xml index ee39557ef..b7b87cdeb 100644 --- a/runbot/templates/utils.xml +++ b/runbot/templates/utils.xml @@ -259,7 +259,12 @@ - + @@ -334,8 +339,8 @@ - - + + Wake up