Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Xavier-Do committed Dec 18, 2024
1 parent 09b14e1 commit be4d67b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
12 changes: 12 additions & 0 deletions runbot/models/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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}')
Expand Down Expand Up @@ -1269,3 +1280,4 @@ def _github_status(self):

def _parse_config(self):
return set(findall(self._server("tools/config.py"), r'--[\w-]+', ))

11 changes: 8 additions & 3 deletions runbot/templates/utils.xml
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,12 @@
<a t-if="bu.static_run" t-att-href="bu.static_run" class="btn btn-info" title="View result" aria-label="View result">
<i class="fa fa-sign-in"/>
</a>
<a groups="base.group_user" t-if="bu.local_state=='done' and (not bu.parent_id.database_ids or user_id.has_group('runbot.group_runbot_advanced_user')) and bu.requested_action != 'wake_up' and bu.database_ids" href="#" data-runbot="wakeup" t-att-data-runbot-build="bu.id" class="btn btn-default" title="Wake up this build" aria-label="Wake up this build">
<a groups="base.group_user"
t-if="bu._can_wake_up()"
href="#" data-runbot="wakeup" t-att-data-runbot-build="bu.id"
t-attf-class="btn btn-{{'default' if not bu.db_garbage_collected else 'danger'}}"
t-attf-title="Wake up this build {{'' if not bu.db_garbage_collected else '(No database found, may create an empty one)'}}"
aria-label="Wake up this build">
<i class="fa fa-coffee"/>
</a>
<a t-attf-href="/runbot/build/{{bu['id']}}" class="btn btn-default" title="Build details" aria-label="Build details">
Expand Down Expand Up @@ -334,8 +339,8 @@
</a>
</t>
</t>
<t t-if="bu.global_state == 'done'">
<t t-if="bu.requested_action != 'wake_up' and bu.database_ids">
<t t-if="bu.local_state == 'done'">
<t t-if="bu._can_wake_up() and not bu.db_garbage_collected">
<a groups="base.group_user" class="dropdown-item" href="#" data-runbot="wakeup" t-att-data-runbot-build="bu['id']">
<i class="fa fa-coffee"/>
Wake up
Expand Down

0 comments on commit be4d67b

Please sign in to comment.