From 2b70c0bcc4bfc868d297c99db8f71e17c57f0ec4 Mon Sep 17 00:00:00 2001 From: Xavier-Do Date: Fri, 10 Jan 2020 14:14:55 +0100 Subject: [PATCH] Revert "[IMP] runbot: use counts for global states" This reverts commit 54f9b9b546086191386be6c10a236bfb2e9bd3bf. The main reason is linked to inconsistency in state compute because of error in nb_ computations. This was to avoid concurrent update, witch is not a such a big problem now since workers are no longer using crons. (retry on failure is faster). --- runbot/models/build.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/runbot/models/build.py b/runbot/models/build.py index f76052b3..9ac59763 100644 --- a/runbot/models/build.py +++ b/runbot/models/build.py @@ -118,7 +118,7 @@ class runbot_build(models.Model): for build in self: build.log_list = ','.join({step.name for step in build.config_id.step_ids() if step._has_log()}) - @api.depends('nb_testing', 'nb_pending', 'local_state', 'duplicate_id.global_state') + @api.depends('children_ids.global_state', 'local_state', 'duplicate_id.global_state') def _compute_global_state(self): # could we use nb_pending / nb_testing ? not in a compute, but in a update state method for record in self: @@ -126,10 +126,14 @@ class runbot_build(models.Model): record.global_state = record.duplicate_id.global_state else: waiting_score = record._get_state_score('waiting') - if record._get_state_score(record.local_state) < waiting_score or record.nb_pending + record.nb_testing == 0: - record.global_state = record.local_state + if record._get_state_score(record.local_state) > waiting_score and record.children_ids: # if finish, check children + children_state = record._get_youngest_state([child.global_state for child in record.children_ids]) + if record._get_state_score(children_state) > waiting_score: + record.global_state = record.local_state + else: + record.global_state = 'waiting' else: - record.global_state = 'waiting' + record.global_state = record.local_state def _get_youngest_state(self, states): index = min([self._get_state_score(state) for state in states])