diff --git a/runbot/container.py b/runbot/container.py
index 13758da1..e5538340 100644
--- a/runbot/container.py
+++ b/runbot/container.py
@@ -172,18 +172,9 @@ def _docker_run(cmd=False, log_path=False, build_dir=False, container_name=False
if ro_volumes:
for dest, source in ro_volumes.items():
logs.write("Adding readonly volume '%s' pointing to %s \n" % (dest, source))
- volumes[source] = {'bind': f'/data/build/{dest}', 'mode': 'ro'}
+ volumes[source] = {'bind': dest, 'mode': 'ro'}
logs.close()
- serverrc_path = os.path.expanduser('~/.openerp_serverrc')
- odoorc_path = os.path.expanduser('~/.odoorc')
- final_rc = odoorc_path if os.path.exists(odoorc_path) else serverrc_path if os.path.exists(serverrc_path) else None
- rc_content = cmd_object.get_config(starting_config=open(final_rc, 'r').read() if final_rc else '')
- rc_path = os.path.join(build_dir, '.odoorc')
- with open(rc_path, 'w') as rc_file:
- rc_file.write(rc_content)
- volumes[rc_path] = {'bind': '/home/odoo/.odoorc', 'mode': 'ro'}
-
ports = {}
if exposed_ports:
for dp, hp in enumerate(exposed_ports, start=8069):
diff --git a/runbot/data/runbot_data.xml b/runbot/data/runbot_data.xml
index c93d3f6d..fae57653 100644
--- a/runbot/data/runbot_data.xml
+++ b/runbot/data/runbot_data.xml
@@ -35,6 +35,11 @@
+
+ runbot.runbot_default_odoorc
+ [options]\nadmin_passwd=running_master_password
+
+
diff --git a/runbot/models/build.py b/runbot/models/build.py
index 4fc1b81f..3db7c9c7 100644
--- a/runbot/models/build.py
+++ b/runbot/models/build.py
@@ -744,8 +744,12 @@ class BuildResult(models.Model):
build._log("run", message, level='ERROR')
build._kill(result='ko')
- def _docker_run(self, **kwargs):
+ def _docker_run(self, cmd=None, ro_volumes=None, **kwargs):
self.ensure_one()
+ _ro_volumes = ro_volumes or {}
+ ro_volumes = {}
+ for dest, source in _ro_volumes.items():
+ ro_volumes[f'/data/build/{dest}'] = source
if 'image_tag' not in kwargs:
kwargs.update({'image_tag': self.params_id.dockerfile_id.image_tag})
if kwargs['image_tag'] != 'odoo:DockerDefault':
@@ -758,7 +762,16 @@ class BuildResult(models.Model):
start_step_time = int(dt2time(self.docker_start) - dt2time(self.job_start))
if start_step_time > 60:
_logger.info('Step took %s seconds before starting docker', start_step_time)
- docker_run(**kwargs)
+
+ starting_config = self.env['ir.config_parameter'].sudo().get_param('runbot.runbot_default_odoorc')
+ if isinstance(cmd, Command):
+ rc_content = cmd.get_config(starting_config=starting_config)
+ else:
+ rc_content = starting_config
+ self.write_file('.odoorc', rc_content)
+ ro_volumes['/home/odoo/.odoorc'] = self._path('.odoorc')
+ kwargs.pop('build_dir', False) # todo check python steps
+ docker_run(cmd=cmd, build_dir=self._path(), ro_volumes=ro_volumes, **kwargs)
def _path(self, *l, **kw):
"""Return the repo build path"""
diff --git a/runbot/models/build_config.py b/runbot/models/build_config.py
index 8d178e3a..8c2c639b 100644
--- a/runbot/models/build_config.py
+++ b/runbot/models/build_config.py
@@ -386,12 +386,11 @@ class ConfigStep(models.Model):
env_variables = self.additionnal_env.split(';') if self.additionnal_env else []
docker_name = build._get_docker_name()
- build_path = build._path()
build_port = build.port
self.env.cr.commit() # commit before docker run to be 100% sure that db state is consistent with dockers
self.invalidate_cache()
self.env['runbot.runbot']._reload_nginx()
- return dict(cmd=cmd, log_path=log_path, build_dir=build_path, container_name=docker_name, exposed_ports=[build_port, build_port + 1], ro_volumes=exports, env_variables=env_variables)
+ return dict(cmd=cmd, log_path=log_path, container_name=docker_name, exposed_ports=[build_port, build_port + 1], ro_volumes=exports, env_variables=env_variables)
def _run_install_odoo(self, build, log_path):
@@ -476,7 +475,7 @@ class ConfigStep(models.Model):
max_timeout = int(self.env['ir.config_parameter'].get_param('runbot.runbot_timeout', default=10000))
timeout = min(self.cpu_limit, max_timeout)
env_variables = self.additionnal_env.split(';') if self.additionnal_env else []
- return dict(cmd=cmd, log_path=log_path, build_dir=build._path(), container_name=build._get_docker_name(), cpu_limit=timeout, ro_volumes=exports, env_variables=env_variables)
+ return dict(cmd=cmd, log_path=log_path, container_name=build._get_docker_name(), cpu_limit=timeout, ro_volumes=exports, env_variables=env_variables)
def _upgrade_create_childs(self):
pass
@@ -713,7 +712,7 @@ class ConfigStep(models.Model):
exception_env = self.env['runbot.upgrade.exception']._generate()
if exception_env:
env_variables.append(exception_env)
- return dict(cmd=migrate_cmd, log_path=log_path, build_dir=build._path(), container_name=build._get_docker_name(), cpu_limit=timeout, ro_volumes=exports, env_variables=env_variables, image_tag=target.params_id.dockerfile_id.image_tag)
+ return dict(cmd=migrate_cmd, log_path=log_path, container_name=build._get_docker_name(), cpu_limit=timeout, ro_volumes=exports, env_variables=env_variables, image_tag=target.params_id.dockerfile_id.image_tag)
def _run_restore(self, build, log_path):
# exports = build._checkout()
@@ -756,7 +755,7 @@ class ConfigStep(models.Model):
])
- return dict(cmd=cmd, log_path=log_path, build_dir=build._path(), container_name=build._get_docker_name(), cpu_limit=self.cpu_limit)
+ return dict(cmd=cmd, log_path=log_path, container_name=build._get_docker_name(), cpu_limit=self.cpu_limit)
def _reference_builds(self, bundle, trigger):
upgrade_dumps_trigger_id = trigger.upgrade_dumps_trigger_id
diff --git a/runbot/models/res_config_settings.py b/runbot/models/res_config_settings.py
index b029c0db..956010af 100644
--- a/runbot/models/res_config_settings.py
+++ b/runbot/models/res_config_settings.py
@@ -20,6 +20,7 @@ class ResConfigSettings(models.TransientModel):
runbot_update_frequency = fields.Integer('Update frequency (in seconds)')
runbot_template = fields.Char('Postgresql template', help="Postgresql template to use when creating DB's")
runbot_message = fields.Text('Frontend warning message')
+ runbot_default_odoorc = fields.Text('Default odoorc for builds')
runbot_upgrade_exception_message = fields.Text('Upgrade exception message')
runbot_do_fetch = fields.Boolean('Discover new commits')
runbot_do_schedule = fields.Boolean('Schedule builds')
@@ -52,6 +53,7 @@ class ResConfigSettings(models.TransientModel):
runbot_update_frequency=int(get_param('runbot.runbot_update_frequency', default=10)),
runbot_template=get_param('runbot.runbot_db_template'),
runbot_message=get_param('runbot.runbot_message', default=''),
+ runbot_default_odoorc=get_param('runbot.runbot_default_odoorc'),
runbot_upgrade_exception_message=get_param('runbot.runbot_upgrade_exception_message'),
runbot_do_fetch=get_param('runbot.runbot_do_fetch', default=False),
runbot_do_schedule=get_param('runbot.runbot_do_schedule', default=False),
@@ -72,6 +74,7 @@ class ResConfigSettings(models.TransientModel):
set_param('runbot.runbot_update_frequency', self.runbot_update_frequency)
set_param('runbot.runbot_db_template', self.runbot_template)
set_param('runbot.runbot_message', self.runbot_message)
+ set_param('runbot.runbot_default_odoorc', self.runbot_default_odoorc)
set_param('runbot.runbot_upgrade_exception_message', self.runbot_upgrade_exception_message)
set_param('runbot.runbot_do_fetch', self.runbot_do_fetch)
set_param('runbot.runbot_do_schedule', self.runbot_do_schedule)
diff --git a/runbot/tests/test_upgrade.py b/runbot/tests/test_upgrade.py
index 5a61450d..582016fc 100644
--- a/runbot/tests/test_upgrade.py
+++ b/runbot/tests/test_upgrade.py
@@ -438,11 +438,12 @@ class TestUpgradeFlow(RunbotCase):
self.patchers['docker_run'].assert_called()
def docker_run_upgrade(cmd, *args, ro_volumes=False, **kwargs):
+ self.assertTrue(ro_volumes.pop('/home/odoo/.odoorc').startswith('/tmp/runbot_test/static/build/'))
self.assertEqual(
ro_volumes, {
- 'addons': '/tmp/runbot_test/static/sources/addons/addons120',
- 'server': '/tmp/runbot_test/static/sources/server/server120',
- 'upgrade': '/tmp/runbot_test/static/sources/upgrade/123abc789'
+ '/data/build/addons': '/tmp/runbot_test/static/sources/addons/addons120',
+ '/data/build/server': '/tmp/runbot_test/static/sources/server/server120',
+ '/data/build/upgrade': '/tmp/runbot_test/static/sources/upgrade/123abc789',
},
"other commit should have been added automaticaly"
)
diff --git a/runbot/views/res_config_settings_views.xml b/runbot/views/res_config_settings_views.xml
index 0942654d..ad15e30a 100644
--- a/runbot/views/res_config_settings_views.xml
+++ b/runbot/views/res_config_settings_views.xml
@@ -68,6 +68,8 @@
+
+