[IMP] runbot: add an option on step to disable logdb

This commit is contained in:
Xavier-Do 2023-04-28 12:44:03 +02:00 committed by Christophe Monniez
parent f6eb23f896
commit 5a5e7693d4
3 changed files with 12 additions and 10 deletions

View File

@ -1012,7 +1012,7 @@ class BuildResult(models.Model):
_logger.error('None of %s found in commit, actual commit content:\n %s' % (commit.repo_id.server_files, os.listdir(commit._source_path())))
raise RunbotException('No server found in %s' % commit.dname)
def _cmd(self, python_params=None, py_version=None, local_only=True, sub_command=None):
def _cmd(self, python_params=None, py_version=None, local_only=True, sub_command=None, enable_log_db=True):
"""Return a list describing the command to start the build
"""
self.ensure_one()
@ -1056,11 +1056,12 @@ class BuildResult(models.Model):
elif grep(config_path, "--xmlrpc-interface"):
command.add_config_tuple("xmlrpc_interface", "127.0.0.1")
log_db = self.env['ir.config_parameter'].get_param('runbot.logdb_name')
if grep(config_path, "log-db"):
command.add_config_tuple("log_db", log_db)
if grep(config_path, 'log-db-level'):
command.add_config_tuple("log_db_level", '25')
if enable_log_db:
log_db = self.env['ir.config_parameter'].get_param('runbot.logdb_name')
if grep(config_path, "log-db"):
command.add_config_tuple("log_db", log_db)
if grep(config_path, 'log-db-level'):
command.add_config_tuple("log_db_level", '25')
if grep(config_path, "data-dir"):
datadir = build._path('datadir')

View File

@ -163,6 +163,7 @@ class ConfigStep(models.Model):
sub_command = fields.Char('Subcommand', tracking=True)
extra_params = fields.Char('Extra cmd args', tracking=True)
additionnal_env = fields.Char('Extra env', help='Example: foo="bar";bar="foo". Cannot contains \' ', tracking=True)
enable_log_db = fields.Boolean("Enable log db", default=True)
# python
python_code = fields.Text('Python code', tracking=True, default=PYTHON_DEFAULT)
python_result_code = fields.Text('Python code for result', tracking=True, default=PYTHON_DEFAULT)
@ -357,10 +358,9 @@ class ConfigStep(models.Model):
exports = build._checkout()
# adjust job_end to record an accurate job_20 job_time
build._log('run', 'Start running build %s' % build.dest)
# run server
cmd = build._cmd(local_only=False)
cmd = build._cmd(local_only=False, enable_log_db=self.enable_log_db)
available_options = build.parse_config()
@ -416,7 +416,7 @@ class ConfigStep(models.Model):
python_params = ['-m', 'coverage', 'run', '--branch', '--source', '/data/build'] + coverage_extra_params
elif self.flamegraph:
python_params = ['-m', 'flamegraph', '-o', self._perfs_data_path()]
cmd = build._cmd(python_params, py_version, sub_command=self.sub_command)
cmd = build._cmd(python_params, py_version, sub_command=self.sub_command, enable_log_db=self.enable_log_db)
# create db if needed
db_suffix = build.params_id.config_data.get('db_name') or (build.params_id.dump_db.db_suffix if not self.create_db else False) or self.db_name
db_name = '%s-%s' % (build.dest, db_suffix)
@ -715,7 +715,7 @@ class ConfigStep(models.Model):
db_suffix = build.params_id.config_data.get('db_name') or build.params_id.dump_db.db_suffix
migrate_db_name = '%s-%s' % (build.dest, db_suffix) # only ok if restore does not force db_suffix
migrate_cmd = build._cmd()
migrate_cmd = build._cmd(enable_log_db=self.enable_log_db)
migrate_cmd += ['-u all']
migrate_cmd += ['-d', migrate_db_name]
migrate_cmd += ['--stop-after-init']

View File

@ -77,6 +77,7 @@
<group string="Extra Parameters" attrs="{'invisible': [('job_type', 'not in', ('python', 'install_odoo', 'test_upgrade', 'run_odoo'))]}">
<field name="extra_params"/>
<field name="additionnal_env"/>
<field name="enable_log_db"/>
</group>
<group string="Create settings" attrs="{'invisible': [('job_type', 'not in', ('python', 'create_build'))]}">
<field name="create_config_ids" widget="many2many_tags" options="{'no_create': True}" />