From af7a0751fc5ffa2e75ec9161d0002399a30ca316 Mon Sep 17 00:00:00 2001 From: Xavier-Do Date: Tue, 20 Dec 2022 08:53:45 +0100 Subject: [PATCH] [FIX] runbot: avoid recursion in create steps Since the custom create was introduced, if a config is added in the config data of a create step, the config can be dynamic. If the given config contains a create step, this become recursive. This is fixed in this commit by: - Checking the parent_path depth in add_child. This will also work for python config. - Consuming the params when adding the child - Also cleanup the base custom multi config to use a specific step --- runbot/data/runbot_build_config_data.xml | 10 +++++++++- runbot/models/build.py | 5 +++++ runbot/models/build_config.py | 5 ++--- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/runbot/data/runbot_build_config_data.xml b/runbot/data/runbot_build_config_data.xml index e320c92b..8bb9c190 100644 --- a/runbot/data/runbot_build_config_data.xml +++ b/runbot/data/runbot_build_config_data.xml @@ -149,10 +149,18 @@ + + custom_multi + create_build + 0 + + + + Custom Multi Generic multibuild to use with custom trigger wizard - + diff --git a/runbot/models/build.py b/runbot/models/build.py index a8b2ba7f..e1ca1f88 100644 --- a/runbot/models/build.py +++ b/runbot/models/build.py @@ -345,6 +345,11 @@ class BuildResult(models.Model): return res def _add_child(self, param_values, orphan=False, description=False, additionnal_commit_links=False): + + if len(self.parent_path.split('/')) > 8: + self._log('_run_create_build', 'This is too deep, skipping create') + return self + if additionnal_commit_links: commit_link_ids = self.params_id.commit_link_ids commit_link_ids |= additionnal_commit_links diff --git a/runbot/models/build_config.py b/runbot/models/build_config.py index c71ad46b..2648a085 100644 --- a/runbot/models/build_config.py +++ b/runbot/models/build_config.py @@ -289,13 +289,13 @@ class ConfigStep(models.Model): config_data = build.params_id.config_data config_ids = config_data.get('create_config_ids', self.create_config_ids) - child_data_list = config_data.get('child_data',[{}]) + child_data_list = config_data.get('child_data', [{}]) if not isinstance(child_data_list, list): child_data_list = [child_data_list] for child_data in child_data_list: for create_config in self.env['runbot.build.config'].browse(child_data.get('config_id', config_ids.ids)): - _child_data = {**child_data, 'config_id': create_config} + _child_data = {'config_data': {}, **child_data, 'config_id': create_config} for _ in range(config_data.get('number_build', self.number_builds)): count += 1 if count > 200: @@ -304,7 +304,6 @@ class ConfigStep(models.Model): child = build._add_child(_child_data, orphan=self.make_orphan) build._log('create_build', 'created with config %s' % create_config.name, log_type='subbuild', path=str(child.id)) - def make_python_ctx(self, build): return { 'self': self,