From b539112a7eaad037ca4b6b8a9bad2f001cf10097 Mon Sep 17 00:00:00 2001 From: Christophe Monniez Date: Thu, 9 May 2019 14:14:39 +0200 Subject: [PATCH] [FIX] runbot: make the cpu limit the same as the runbot timeout When a build exceeds the cpu limit, it is simply killed by the kernel. As a safeguard the "Initiating shutdown." sentence should be searched in the log file, and the build marked as "ko" if not found. Unfortunateley, there is no period (.) at the end of the sentence in the Odoo logs (see: https://github.com/odoo/odoo/blob/12.0/odoo/service/server.py#L444) Thus, this condition is never fulfilled. On top of that, this was masked by the first part of the condition, checking that the 'test/common.py' has no "post_install" string. The "test" directory does not exists in Odoo ( but "tests" exists) , so the condition was always falsy. Finally, a build can be marked as "ok" when he is killed and no errors are found until the kill. With this commit: * The legacy grep for post_install is removed as it now exists in all Odoo supported versions. * The period typo is fixed. * A log is inserted when the final sentence is not found. * The cpu_limit is set as the same as the runbot_timeout parameter for better consitency. * The time exceeded log message is now logged in the build instead of the runbot log. Co-authored-by: @Xavier-Do --- runbot/models/build.py | 12 ++++++++---- runbot/models/res_config_settings.py | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/runbot/models/build.py b/runbot/models/build.py index 022766b4..d0f12cc4 100644 --- a/runbot/models/build.py +++ b/runbot/models/build.py @@ -354,7 +354,7 @@ class runbot_build(models.Model): icp = self.env['ir.config_parameter'] # For retro-compatibility, keep this parameter in seconds - default_timeout = int(icp.get_param('runbot.runbot_timeout', default=1800)) / 60 + default_timeout = int(icp.get_param('runbot.runbot_timeout', default=3600)) / 60 for build in self: if build.state == 'deathrow': @@ -378,7 +378,7 @@ class runbot_build(models.Model): # kill if overpassed timeout = (build.branch_id.job_timeout or default_timeout) * 60 * ( build.coverage and 1.5 or 1) if build.job != jobs[-1] and build.job_time > timeout: - build._logger('%s time exceded (%ss)', build.job, build.job_time) + build._log('schedule', '%s time exceeded (%ss)', build.job, build.job_time) build.write({'job_end': now()}) build._kill(result='killed') else: @@ -742,7 +742,7 @@ class runbot_build(models.Model): @runbot_job('testing', 'running') def _job_20_test_all(self, build, log_path): - cpu_limit = 2400 + cpu_limit = self.env['ir.config_parameter'].get_param('runbot.runbot_timeout', default=3600) self._local_pg_createdb("%s-all" % build.dest) cmd, mods = build._cmd() build._log('test_all', 'Start test all modules') @@ -805,9 +805,13 @@ class runbot_build(models.Model): v['result'] = "ko" elif rfind(log_all, _re_warning): v['result'] = "warn" - elif not grep(build._server("test/common.py"), "post_install") or grep(log_all, "Initiating shutdown."): + elif not grep(log_all, "Initiating shutdown"): + v['result'] = "ko" + build._log('run', "Seems that the build was stopped too early. The cpu_limit could have been reached") + elif not build.result: v['result'] = "ok" else: + build._log('run', "Modules not loaded") v['result'] = "ko" build.write(v) build._github_status() diff --git a/runbot/models/res_config_settings.py b/runbot/models/res_config_settings.py index 4fa89973..9cac79d5 100644 --- a/runbot/models/res_config_settings.py +++ b/runbot/models/res_config_settings.py @@ -22,7 +22,7 @@ class ResConfigSettings(models.TransientModel): get_param = self.env['ir.config_parameter'].sudo().get_param res.update(runbot_workers=int(get_param('runbot.runbot_workers', default=6)), runbot_running_max=int(get_param('runbot.runbot_running_max', default=75)), - runbot_timeout=int(get_param('runbot.runbot_timeout', default=1800)), + runbot_timeout=int(get_param('runbot.runbot_timeout', default=3600)), runbot_starting_port=int(get_param('runbot.runbot_starting_port', default=2000)), runbot_domain=get_param('runbot.runbot_domain', default=common.fqdn()), runbot_max_age=int(get_param('runbot.runbot_max_age', default=30)),