set module build state to 'failed' imediately

Fixes #1009

Signed-off-by: Valerij Maljulin <vmaljuli@redhat.com>
This commit is contained in:
Valerij Maljulin
2018-11-09 09:03:55 +01:00
parent 290f19d477
commit 8adce7593b
2 changed files with 14 additions and 0 deletions

View File

@@ -78,12 +78,14 @@ def start_build_component(builder, c):
c.state = koji.BUILD_STATES['FAILED']
c.state_reason = "Failed to build artifact %s: %s" % (c.package, str(e))
log.exception(e)
c.module_build.transition(conf, models.BUILD_STATES['failed'])
return
if not c.task_id and c.state == koji.BUILD_STATES['BUILDING']:
c.state = koji.BUILD_STATES['FAILED']
c.state_reason = ("Failed to build artifact %s: "
"Builder did not return task ID" % (c.package))
c.module_build.transition(conf, models.BUILD_STATES['failed'])
return

View File

@@ -861,6 +861,18 @@ class TestBatches:
# Make sure that both components in the batch were submitted
assert len(mock_sbc.mock_calls) == 2
def test_start_build_component_failed_state(self, default_buildroot_groups):
"""
Tests whether exception occured while building sets the state to failed
"""
builder = mock.MagicMock()
builder.build.side_effect = Exception('Something have gone terribly wrong')
component = mock.MagicMock()
module_build_service.utils.batches.start_build_component(builder, component)
assert component.state == koji.BUILD_STATES['FAILED']
@patch('module_build_service.utils.batches.start_build_component')
@patch('module_build_service.config.Config.rebuild_strategy',
new_callable=mock.PropertyMock, return_value='only-changed')