Reference slot instead of build - #1477
Draft
Xavier-Do wants to merge 1 commit into
Draft
Conversation
Contributor
Author
|
This may need to make link child optionnal diff --git a/runbot/models/build.py b/runbot/models/build.py
index ecb76275..a1f90ce8 100644
--- a/runbot/models/build.py
+++ b/runbot/models/build.py
@@ -410,11 +410,14 @@ class BuildResult(models.Model):
children_ids += [link.child_id.id for link in record.child_link_ids if not link.orphan_result and not link.child_id.orphan_result]
children = self.browse(children_ids)
if record._get_state_score(record.local_state) > waiting_score and children: # if finish, check children
- children_state = record._get_youngest_state([child.global_state for child in children])
- if record._get_state_score(children_state) > waiting_score:
- record.global_state = record.local_state
- else:
+ if any(not link.child_id for link in record.child_link_ids):
record.global_state = 'waiting'
+ else:
+ children_state = record._get_youngest_state([child.global_state for child in children])
+ if record._get_state_score(children_state) > waiting_score:
+ record.global_state = record.local_state
+ else:
+ record.global_state = 'waiting'
else:
record.global_state = record.local_state
@@ -1878,15 +1881,18 @@ class BuildLink(models.Model):
_order = 'id desc'
parent_id = fields.Many2one('runbot.build', string='Parent Build', required=True, ondelete='cascade')
- child_id = fields.Many2one('runbot.build', string='Child Build', required=True, ondelete='cascade')
- params_id = fields.Many2one('runbot.build.params', string='Params', related='child_id.params_id', store=True)
+ child_id = fields.Many2one('runbot.build', string='Child Build', ondelete='cascade')
+ params_id = fields.Many2one('runbot.build.params', string='Params', required=True)
orphan_result = fields.Boolean(string='Orphan Result', help='If set, the result of the child build will not be taken into account for the parent build result')
_no_self_link = models.Constraint('check (parent_id != child_id)', "a build cannot link itself")
- _unique_link = models.Constraint('unique (parent_id, child_id)', "duplicate build link")
+ _unique_link = models.Constraint('unique (parent_id, params_id, child_id)', "duplicate build link")
@api.model_create_multi
def create(self, vals_list):
+ for vals in vals_list:
+ if vals.get('child_id'):
+ vals['params_id'] = self.env['runbot.build'].browse(vals.get('child_id')).params_id.id
links = super().create(vals_list)
links.mapped('parent_id')._update_globals()
return links
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This would allow to create upgrade build before the template is finished
The main issue being that it removes all the logic currently used for upgrades
Not correct in current state
This solution has a main drawback: the build id is the right way to uniquify the parameters of the upgrade since it defines where the database will be downloaded.
Using the slot id is correct but will potentially break some linking since two slot can reference the same build.
Using the parameter is not 100% the same since we may rebuild the build and have a new database for the same params. So the linking could not be done.