Solidify how the previous module state is determined when resuming a failed module build

This commit is contained in:
mprahl
2017-11-06 16:49:49 -05:00
parent 11e39ab0c3
commit 18e7f608b1
2 changed files with 7 additions and 3 deletions

View File

@@ -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():

View File

@@ -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: