From 5552c161023d0571b932e0584195942523c0e453 Mon Sep 17 00:00:00 2001 From: Christophe Monniez Date: Fri, 13 Dec 2019 12:25:42 +0100 Subject: [PATCH] [IMP] runbot: create a broken symlink in all server sources As the --upgrade-paths options does not work as expected in Odoo, a symbolic link has to be created in odoo/addons/base/maintenance pointing to the migration scripts. The runbot uses Docker read-only volumes to access the sources that are shared between builds, preventing the creation of such a link. With this commit, a symbolic link is created right after the export of a commit only when the repo is a "server" repo. This link is broken outside of the Docker volumes but uses the mount points of the sources inside the container. Two ir.config_parameter's are used to enable and configure this feature: * runbot_migration_ln: the relative path where the link should be placed (typically odoo/addons/base/maintenance) * runbot_migration_repo_id: the id of the migration scripts repo, used to determine the name of the mount point inside the Docker container A change is also made in the "reverse dependcy build" to avoid the creation of a build in the migration repo for each push in its dependency. Simply set the no_build field on this migration repo. --- runbot/models/repo.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/runbot/models/repo.py b/runbot/models/repo.py index 7848cca4..9d2fff03 100644 --- a/runbot/models/repo.py +++ b/runbot/models/repo.py @@ -212,6 +212,14 @@ class runbot_repo(models.Model): if err: raise RunbotException("Archive %s failed. Did you force push the branch since build creation? (%s)" % (sha, err)) + # migration scripts link if necessary + icp = self.env['ir.config_parameter'] + ln_param = icp.get_param('runbot_migration_ln', default='') + migration_repo_id = int(icp.get_param('runbot_migration_repo_id', default=0)) + if ln_param and migration_repo_id and self.server_files: + scripts_dir = self.env['runbot.repo'].browse(migration_repo_id)._get_repo_name_part() + os.symlink('/data/build/%s' % scripts_dir, self._source_path(sha, ln_param)) + # TODO get result and fallback on cleaing in case of problem return export_path @@ -368,7 +376,7 @@ class runbot_repo(models.Model): new_build = Build.create(build_info) # create a reverse dependency build if needed if branch.sticky: - for rev_repo in self.search([('dependency_ids', 'in', self.id)]): + for rev_repo in self.search([('dependency_ids', 'in', self.id), ('no_build', '=', False)]): # find the latest build with the same branch name latest_rev_build = Build.search([('build_type', '=', 'normal'), ('hidden', '=', 'False'), ('repo_id.id', '=', rev_repo.id), ('branch_id.branch_name', '=', branch.branch_name)], order='id desc', limit=1) if latest_rev_build: