From ca3e3da35c0746e10dd641a6db6c258852e457b8 Mon Sep 17 00:00:00 2001 From: Giulia Naponiello Date: Mar 09 2020 15:03:26 +0000 Subject: Revert "Revert "No need to convert compose ids or verify 'done' state"" This reverts commit f6fcd09b7aff28992e09c0a03edc72b35a51f35a. --- diff --git a/freshmaker/handlers/__init__.py b/freshmaker/handlers/__init__.py index eda01ea..a7de567 100644 --- a/freshmaker/handlers/__init__.py +++ b/freshmaker/handlers/__init__.py @@ -533,34 +533,18 @@ class ContainerBuildHandler(BaseHandler): if args["renewed_odcs_compose_ids"]: compose_ids += args["renewed_odcs_compose_ids"] - # OSBS cannot handle both repo_urls and compose_ids in the same time. - # We use repo_urls only in special cases to build base images. In this - # cases, we want to convert compose_ids to repository URLs. Otherwise, - # just pass compose_ids to OSBS via Koji. - if repo_urls is not None: - for compose_id in compose_ids: - odcs_compose = self.odcs_get_compose(compose_id) - if odcs_compose["state"] in [COMPOSE_STATES['wait'], - COMPOSE_STATES['generating']]: - # In case the ODCS compose is still generating, raise an - # exception. - msg = ("Compose %s is not in done state. Waiting with " - "rebuild." % (str(compose_id))) - self.log_info(msg) - raise ODCSComposeNotReady(msg) - elif odcs_compose["state"] != COMPOSE_STATES["done"]: - # In case the compose is not in 'done' state, mark the - # build as failed. We should never get expired here, - # because the compose has been submitted just a minutes - # ago. If we get "expired" here, it is sign of an issue, - # because that means we are trying to build quite old - # image. - build.transition( - ArtifactBuildState.FAILED.value, - "Compose %s is not in 'done' state." % str(compose_id)) - return - repo_urls.append(odcs_compose["result_repofile"]) - compose_ids = [] + for compose_id in compose_ids: + odcs_compose = self.odcs_get_compose(compose_id) + if odcs_compose["state"] in [COMPOSE_STATES['wait'], + COMPOSE_STATES['generating']]: + # In case the ODCS compose is still generating, raise an + # exception. + msg = ("Compose %s has not been generated yet. Waiting with " + "rebuild." % (str(compose_id))) + self.log_info(msg) + raise ODCSComposeNotReady(msg) + # OSBS can renew a compose if it needs to, so we can just pass + # it along without further verification for other states. return self.build_container( scm_url, branch, target, repo_urls=repo_urls, diff --git a/tests/test_handler.py b/tests/test_handler.py index a63c8fa..6970d4f 100644 --- a/tests/test_handler.py +++ b/tests/test_handler.py @@ -218,13 +218,10 @@ class TestGetRepoURLs(helpers.ModelsTestCase): handler = MyHandler() handler.build_image_artifact_build(self.build_1, ["http://localhost/x.repo"]) - repo_urls = [ - 'http://localhost/x.repo', 'http://localhost/5.repo', - 'http://localhost/6.repo', 'http://localhost/7.repo', - 'http://localhost/8.repo'] + repo_urls = ['http://localhost/x.repo'] build_container.assert_called_once_with( 'git://pkgs.fedoraproject.org/repo#hash', 'branch', 'target', - arch_override='x86_64', compose_ids=[], isolated=True, + arch_override='x86_64', compose_ids=[5, 6, 7, 8], isolated=True, koji_parent_build=None, release='2', repo_urls=repo_urls) @patch("freshmaker.handlers.ContainerBuildHandler.build_container")