Revert "[IMP] runbot: use counts for global states"

This reverts commit 54f9b9b546.
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).
This commit is contained in:
Xavier-Do 2020-01-10 14:14:55 +01:00
parent 650a93fee7
commit 2b70c0bcc4

View File

@ -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])