From 7d7a45f99705bf26a3becddc1797f93bcc39774e Mon Sep 17 00:00:00 2001 From: Jan Kaluza Date: Wed, 3 May 2017 09:21:55 +0200 Subject: [PATCH] Do not tag built components if there is any failed one. --- .../scheduler/handlers/components.py | 21 +++++++++++++++---- tests/test_build/test_build.py | 6 ++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/module_build_service/scheduler/handlers/components.py b/module_build_service/scheduler/handlers/components.py index 3d190c0f..da3d42ac 100644 --- a/module_build_service/scheduler/handlers/components.py +++ b/module_build_service/scheduler/handlers/components.py @@ -84,6 +84,12 @@ def _finalize(config, session, msg, state): if c.state == koji.BUILD_STATES['BUILDING'] or not c.state ] if not unbuilt_components_in_batch: + failed_components_in_batch = [ + c.nvr for c in parent.current_batch() + if (c.state in [koji.BUILD_STATES['FAILED'], + koji.BUILD_STATES['CANCELED']]) + ] + built_components_in_batch = [ c.nvr for c in parent.current_batch() if c.state == koji.BUILD_STATES['COMPLETE'] @@ -92,11 +98,18 @@ def _finalize(config, session, msg, state): builder = module_build_service.builder.GenericBuilder.create_from_module( session, parent, config) - if not built_components_in_batch: + if not built_components_in_batch or failed_components_in_batch: # If there are no successfully built components in a batch, - # there is nothing to tag and therefore the repository won't - # be regenerated. We generate fake repo change message here. - log.info("Batch done. No component to tag") + # there is nothing to tag. If there is some failed component build, + # we should not tag even the successfully built components, because + # the module build will fail anyway. Repository won't be + # regenerated in these cases and therefore we generate fake repo + # change message here. + if failed_components_in_batch: + log.info("Batch done, but not tagging because of failed " + "component builds.") + else: + log.info("Batch done. No component to tag") further_work += [messaging.KojiRepoChange( 'components::_finalize: fake msg', builder.module_build_tag['name'])] diff --git a/tests/test_build/test_build.py b/tests/test_build/test_build.py index fa3a5ac4..dfba2afa 100644 --- a/tests/test_build/test_build.py +++ b/tests/test_build/test_build.py @@ -558,6 +558,12 @@ class TestBuild(unittest.TestCase): TestModuleBuilder.on_build_cb = on_build_cb + # Check that no components are tagged when single component fails + # in batch. + def on_tag_artifacts_cb(cls, artifacts): + raise ValueError("No component should be tagged.") + TestModuleBuilder.on_tag_artifacts_cb = on_tag_artifacts_cb + msgs = [] stop = module_build_service.scheduler.make_simple_stop_condition(db.session) module_build_service.scheduler.main(msgs, stop)