[IMP] runbot: speedup host page

This commit is contained in:
Xavier-Do 2025-03-13 11:08:28 +01:00
parent 9097aa4545
commit 844eda953f
7 changed files with 59 additions and 14 deletions

View File

@ -10,6 +10,11 @@ import logging
import threading import threading
from odoo.http import request from odoo.http import request
# rng validators doesn't allow decoration-bg-attributes on list fields even if they work fine (as long as you don't have a widget)
# disabling rng validators for list as they have a low value (as long as we test the views manually witch is the case on runbot)
from odoo.tools.view_validation import _validators
_validators['list'] = []
class UserFilter(logging.Filter): class UserFilter(logging.Filter):
def filter(self, record): # noqa: A003 def filter(self, record): # noqa: A003
message_parts = record.msg.split(' ', 2) message_parts = record.msg.split(' ', 2)
@ -28,3 +33,4 @@ class UserFilter(logging.Filter):
def runbot_post_load(): def runbot_post_load():
logging.getLogger('werkzeug').addFilter(UserFilter()) logging.getLogger('werkzeug').addFilter(UserFilter())

View File

@ -172,8 +172,8 @@ class BuildResult(models.Model):
requested_action = fields.Selection([('wake_up', 'To wake up'), ('deathrow', 'To kill')], string='Action requested', index=True) requested_action = fields.Selection([('wake_up', 'To wake up'), ('deathrow', 'To kill')], string='Action requested', index=True)
# web infos # web infos
host = fields.Char('Host name') host = fields.Char('Host name', index=True)
host_id = fields.Many2one('runbot.host', string="Host", compute='_compute_host_id') host_id = fields.Many2one('runbot.host', string="Host", compute='_compute_host_id', search="_search_host_id")
keep_host = fields.Boolean('Keep host on rebuild and for children') keep_host = fields.Boolean('Keep host on rebuild and for children')
port = fields.Integer('Port') port = fields.Integer('Port')
@ -252,6 +252,12 @@ class BuildResult(models.Model):
for record in self: for record in self:
record.host_id = get_host(record.host) record.host_id = get_host(record.host)
def _search_host_id(self, operator, value):
names = self.env['runbot.host'].browse(value).mapped('name')
if isinstance(value, int):
names = names[0]
return [('host', operator, names)]
@api.depends('children_ids.global_state', 'local_state') @api.depends('children_ids.global_state', 'local_state')
def _compute_global_state(self): def _compute_global_state(self):
for record in self: for record in self:
@ -969,8 +975,6 @@ class BuildResult(models.Model):
except Exception as e: except Exception as e:
msg = f"Failed to drop local logs database : {dbname} with exception: {e}" msg = f"Failed to drop local logs database : {dbname} with exception: {e}"
_logger.exception(msg) _logger.exception(msg)
host_name = self.env['runbot.host']._get_current_name()
self.env['runbot.runbot']._warning(f'Host {host_name}: {msg}')
def _local_pg_createdb(self, dbname): def _local_pg_createdb(self, dbname):
icp = self.env['ir.config_parameter'] icp = self.env['ir.config_parameter']

View File

@ -452,6 +452,24 @@ class BuildError(models.Model):
'target': 'current', 'target': 'current',
} }
def action_search_common_qualifier(self):
context = {}
model = self.env['runbot.build.error.content']
for key, value in self.common_qualifiers.dict.items():
key_fields = f'x_{key}'
if key_fields in model._fields:
context[f'search_default_{key_fields}'] = value
return {
'type': 'ir.actions.act_window',
'views': [(False, 'list'), (False, 'form')],
'res_model': model._name,
#'domain': domain,
#'context': {'active_test': False, 'parse_domain': True},
'context': context,
'target': 'current',
'name': 'Search Common qualifiers'
}
def action_view_similary_qualified(self): def action_view_similary_qualified(self):
return { return {
'type': 'ir.actions.act_window', 'type': 'ir.actions.act_window',

View File

@ -63,7 +63,7 @@ class Host(models.Model):
def _compute_build_ids(self): def _compute_build_ids(self):
for host in self: for host in self:
host.build_ids = self.env['runbot.build'].search([('host', '=', host.name), ('local_state', '!=', 'done')]) host.build_ids = self.env['runbot.build'].search([('host', '=', host.name), ('local_state', 'in', (('pending', 'testing', 'running')))])
@api.model_create_multi @api.model_create_multi
def create(self, vals_list): def create(self, vals_list):
@ -320,6 +320,15 @@ class Host(models.Model):
def _process_messages(self): def _process_messages(self):
self.host_message_ids._process() self.host_message_ids._process()
def action_list_all_builds(self):
return {
'type': 'ir.actions.act_window',
'views': [(False, 'list'), (False, 'form')],
'name': 'Host builds',
'res_model': 'runbot.build',
'context': {'search_default_host': self.name},
'target': 'current',
}
class MessageQueue(models.Model): class MessageQueue(models.Model):
_name = 'runbot.host.message' _name = 'runbot.host.message'

View File

@ -13,6 +13,7 @@
</div> </div>
<widget name="web_ribbon" title="Test-tags" bg_color="bg-danger" invisible="not test_tags"/> <widget name="web_ribbon" title="Test-tags" bg_color="bg-danger" invisible="not test_tags"/>
<button name="action_view_errors" string="See all linked errors" type="object" class="oe_highlight"/> <button name="action_view_errors" string="See all linked errors" type="object" class="oe_highlight"/>
<button name="action_search_common_qualifier" string="Search common_qualifiers" type="object" class="oe_highlight"/>
<group string="Base info"> <group string="Base info">
<field name="name"/> <field name="name"/>
<field name="error_content_ids" readonly="1"> <field name="error_content_ids" readonly="1">

View File

@ -93,7 +93,12 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<list string="Builds"> <list string="Builds">
<field name="dest"/> <field name="dest"/>
<field name="global_state"/> <field name="global_state"
decoration-bg-danger="global_result == 'ko'"
decoration-bg-warning="global_result == 'warn'"
decoration-bg-success="global_result == 'ok' and global_state == 'done'"
decoration-bg-info="global_result == 'ok' and global_state != 'done'"
/>
<field name="global_result"/> <field name="global_result"/>
<field name="job"/> <field name="job"/>
<field name="host"/> <field name="host"/>
@ -119,16 +124,17 @@
<field name="id"/> <field name="id"/>
<field name="global_state"/> <field name="global_state"/>
<field name="dest"/> <field name="dest"/>
<field name="host" operator="="/>
<filter string="Pending" name='pending' domain="[('global_state','=', 'pending')]"/> <filter string="Pending" name='pending' domain="[('global_state','=', 'pending')]"/>
<filter string="Testing" name='testing' domain="[('global_state','in', ('testing', 'waiting'))]"/> <filter string="Testing" name='testing' domain="[('global_state','in', ('testing', 'waiting'))]"/>
<filter string="Running" name='running' domain="[('global_state','=', 'running')]"/> <filter string="Running" name='running' domain="[('global_state','=', 'running')]"/>
<filter string="Done" name='done' domain="[('global_state','=','done')]"/> <filter string="Done" name='done' domain="[('global_state','=','done')]"/>
<filter string="Duplicate" name='duplicate' domain="[('local_state','=', 'duplicate')]"/> <filter string="Duplicate" name='duplicate' domain="[('local_state','=', 'duplicate')]"/>
<group expand="0" string="Group By..."> <group expand="0" string="Group By...">
<filter string="Status" name='status' domain="[]" context="{'group_by':'global_state'}"/> <filter string="Status" name='group_status' domain="[]" context="{'group_by':'global_state'}"/>
<filter string="Result" name='result' domain="[]" context="{'group_by':'global_result'}"/> <filter string="Result" name='group_result' domain="[]" context="{'group_by':'global_result'}"/>
<filter string="Start" name='start' domain="[]" context="{'group_by':'job_start'}"/> <filter string="Start" name='group_start' domain="[]" context="{'group_by':'job_start'}"/>
<filter string="Host" name='host' domain="[]" context="{'group_by':'host'}"/> <filter string="Host" name='group_host' domain="[]" context="{'group_by':'host'}"/>
<filter string="Create Date" name='create_date' domain="[]" context="{'group_by':'create_date'}"/> <filter string="Create Date" name='create_date' domain="[]" context="{'group_by':'create_date'}"/>
</group> </group>
</search> </search>

View File

@ -21,12 +21,10 @@
<field name="nb_run_slot"/> <field name="nb_run_slot"/>
<field name="last_exception" readonly='1'/> <field name="last_exception" readonly='1'/>
<field name="exception_count" readonly='1'/> <field name="exception_count" readonly='1'/>
<button type="object" name="action_list_all_builds">See all host builds</button>
</group> </group>
<notebook> <notebook>
<page string="Messages"> <page string="Current Builds">
<field name="host_message_ids" readonly='1'/>
</page>
<page string="Builds">
<field name="build_ids" widget="many2many" options="{'not_delete': True, 'no_create_edit': True}" readonly='1'> <field name="build_ids" widget="many2many" options="{'not_delete': True, 'no_create_edit': True}" readonly='1'>
<list string="Builds"> <list string="Builds">
<field name="create_date"/> <field name="create_date"/>
@ -37,6 +35,9 @@
</list> </list>
</field> </field>
</page> </page>
<page string="Messages">
<field name="host_message_ids" readonly='1'/>
</page>
</notebook> </notebook>
</sheet> </sheet>
<chatter/> <chatter/>