mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-04 19:28:49 +08:00
Solidify how the previous module state is determined when resuming a failed module build
This commit is contained in:
@@ -221,6 +221,12 @@ class ModuleBuild(MBSBase):
|
||||
raise ValueError("Invalid modulemd")
|
||||
return mmd
|
||||
|
||||
@property
|
||||
def previous_non_failed_state(self):
|
||||
for trace in reversed(self.module_builds_trace):
|
||||
if trace.state != BUILD_STATES['failed']:
|
||||
return trace.state
|
||||
|
||||
@validates('state')
|
||||
def validate_state(self, key, field):
|
||||
if field in BUILD_STATES.values():
|
||||
|
||||
@@ -969,9 +969,7 @@ def submit_module_build(username, url, mmd, scm, optional_params=None):
|
||||
component.state = None
|
||||
db.session.add(component)
|
||||
module.username = username
|
||||
# The last transition in the trace will be "failed", but we want to determine what the
|
||||
# state was previous to the failure.
|
||||
prev_state = module.module_builds_trace[-2].state
|
||||
prev_state = module.previous_non_failed_state
|
||||
if prev_state == models.BUILD_STATES['init']:
|
||||
transition_to = models.BUILD_STATES['init']
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user