From 0d29643d52f6cbdb4a011a3704c97983ee97ebde Mon Sep 17 00:00:00 2001 From: Xavier-Do Date: Thu, 23 Mar 2023 16:11:00 +0100 Subject: [PATCH] [IMP] runbot: add a separate pending count The assigned build are in the same count of the pending build. This can sometimes create a false queue, because you can have 1000 pending builds on one host, this doesn't mean that a new standard build cannot be immediatly taken by another host. This is mainly to hide the false queue created by the full charge zfs build currently running and creating ~400 assigned build. --- runbot/controllers/frontend.py | 31 ++++++++++++++++++------------- runbot/templates/dashboard.xml | 2 +- runbot/templates/utils.xml | 2 +- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/runbot/controllers/frontend.py b/runbot/controllers/frontend.py index 8969be69..ebb8a4f9 100644 --- a/runbot/controllers/frontend.py +++ b/runbot/controllers/frontend.py @@ -73,10 +73,11 @@ class Runbot(Controller): ICP = request.env['ir.config_parameter'].sudo().get_param warn = int(ICP('runbot.pending.warning', 5)) crit = int(ICP('runbot.pending.critical', 12)) - pending_count = request.env['runbot.build'].search_count([('local_state', '=', 'pending'), ('build_type', '!=', 'scheduled')]) + pending_count = request.env['runbot.build'].search_count([('local_state', '=', 'pending'), ('build_type', '!=', 'scheduled'), ('host', '=', False)]) scheduled_count = request.env['runbot.build'].search_count([('local_state', '=', 'pending'), ('build_type', '=', 'scheduled')]) + pending_assigned_count = request.env['runbot.build'].search_count([('local_state', '=', 'pending'), ('build_type', '!=', 'scheduled'), ('host', '!=', False)]) level = ['info', 'warning', 'danger'][int(pending_count > warn) + int(pending_count > crit)] - return pending_count, level, scheduled_count + return pending_count, level, scheduled_count, pending_assigned_count @o_route([ '/runbot/submit' @@ -112,12 +113,13 @@ class Runbot(Controller): if not project and projects: project = projects[0] - pending_count, level, scheduled_count = self._pending() + pending_count, level, scheduled_count, pending_assigned_count = self._pending() context = { 'categories': categories, 'search': search, 'message': request.env['ir.config_parameter'].sudo().get_param('runbot.runbot_message'), - 'pending_total': pending_count, + 'pending_count': pending_count, + 'pending_assigned_count': pending_assigned_count, 'pending_level': level, 'scheduled_count': scheduled_count, 'hosts_data': request.env['runbot.host'].search([('assigned_only', '=', False)]), @@ -359,10 +361,11 @@ class Runbot(Controller): def glances(self, project_id=None, **kwargs): project_ids = [project_id] if project_id else request.env['runbot.project'].search([]).ids # search for access rights bundles = request.env['runbot.bundle'].search([('sticky', '=', True), ('project_id', 'in', project_ids)]) - pending = self._pending() + pending_count, level, scheduled_count, pending_assigned_count = self._pending() qctx = { - 'pending_total': pending[0], - 'pending_level': pending[1], + 'pending_count': pending_count, + 'pending_assigned_count': pending_assigned_count, + 'pending_level': level, 'bundles': bundles, 'title': 'Glances' } @@ -372,7 +375,7 @@ class Runbot(Controller): '/runbot/monitoring/', '/runbot/monitoring//'], type='http', auth='user', website=True, sitemap=False) def monitoring(self, category_id=None, view_id=None, **kwargs): - pending = self._pending() + pending_count, level, scheduled_count, pending_assigned_count = self._pending() hosts_data = request.env['runbot.host'].search([]) if category_id: category = request.env['runbot.category'].browse(category_id) @@ -383,9 +386,10 @@ class Runbot(Controller): bundles = request.env['runbot.bundle'].search([('sticky', '=', True)]) # NOTE we dont filter on project qctx = { 'category': category, - 'pending_total': pending[0], - 'pending_level': pending[1], - 'scheduled_count': pending[2], + 'pending_count': pending_count, + 'pending_assigned_count': pending_assigned_count, + 'pending_level': level, + 'scheduled_count': scheduled_count, 'bundles': bundles, 'hosts_data': hosts_data, 'auto_tags': request.env['runbot.build.error'].disabling_tags(), @@ -578,10 +582,11 @@ class Runbot(Controller): build_by_bundle = list(build_by_bundle.items()) build_by_bundle.sort(key=lambda x: -len(x[1])) - pending_count, level, scheduled_count = self._pending() + pending_count, level, scheduled_count, pending_assigned_count = self._pending() context = { 'build_by_bundle': build_by_bundle, - 'pending_total': pending_count, + 'pending_count': pending_count, + 'pending_assigned_count': pending_assigned_count, 'pending_level': level, 'scheduled_count': scheduled_count, 'hosts_data': request.env['runbot.host'].search([('assigned_only', '=', False)]), diff --git a/runbot/templates/dashboard.xml b/runbot/templates/dashboard.xml index d96cdea9..66a34307 100644 --- a/runbot/templates/dashboard.xml +++ b/runbot/templates/dashboard.xml @@ -14,7 +14,7 @@
Pending: - + ()
diff --git a/runbot/templates/utils.xml b/runbot/templates/utils.xml index 9f449450..670eb25e 100644 --- a/runbot/templates/utils.xml +++ b/runbot/templates/utils.xml @@ -168,7 +168,7 @@ Pending: - + ()