From 65a8f6da76e4894a49d52017f80df5942ca47db9 Mon Sep 17 00:00:00 2001 From: Xavier-Do Date: Thu, 28 Sep 2023 14:54:21 +0200 Subject: [PATCH] [IMP] runbot: check dir exists upgrade path --- runbot/models/build.py | 13 +++++++++++-- runbot/models/build_config.py | 6 +----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/runbot/models/build.py b/runbot/models/build.py index 0e0b1c46..f534eb01 100644 --- a/runbot/models/build.py +++ b/runbot/models/build.py @@ -1020,10 +1020,19 @@ class BuildResult(models.Model): for commit in (self.env.context.get('defined_commit_ids') or self.params_id.commit_ids): if not commit.repo_id.manifest_files: continue # skip repo without addons - source_path = self._docker_source_folder(commit) + repo_folder = self._docker_source_folder(commit) for addons_path in (commit.repo_id.addons_paths or '').split(','): if os.path.isdir(commit._source_path(addons_path)): - yield os.sep.join([source_path, addons_path]).strip(os.sep) + yield os.sep.join([repo_folder, addons_path]).strip(os.sep) + + def _get_upgrade_path(self): + for commit in (self.env.context.get('defined_commit_ids') or self.params_id.commit_ids): + if not commit.repo_id.upgrade_paths: + continue # skip repo without addons + repo_folder = self._docker_source_folder(commit) + for upgrade_path in commit.repo_id.upgrade_paths.split(','): + if os.path.isdir(commit._source_path(upgrade_path)): + yield os.sep.join([repo_folder, upgrade_path]).strip(os.sep) def _get_server_info(self, commit=None): commit = commit or self._get_server_commit() diff --git a/runbot/models/build_config.py b/runbot/models/build_config.py index c243b744..f13da2e7 100644 --- a/runbot/models/build_config.py +++ b/runbot/models/build_config.py @@ -702,11 +702,7 @@ class ConfigStep(models.Model): migrate_cmd += ['-d', migrate_db_name] migrate_cmd += ['--stop-after-init'] migrate_cmd += ['--max-cron-threads=0'] - upgrade_paths = [] - for repo in target_commit_ids.mapped('repo_id'): - if repo.upgrade_paths: - for upgrade_path in repo.upgrade_paths.split(','): - upgrade_paths.append(repo.name + upgrade_path.replace(' ', '')) + upgrade_paths = list(build._get_upgrade_path()) if upgrade_paths: migrate_cmd += ['--upgrade-path', ','.join(upgrade_paths)]