From a15a3d3cb9071b196e5e757d01622c84e5fb175d Mon Sep 17 00:00:00 2001 From: Tim Waugh Date: Sun, 22 May 2016 18:54:29 +0100 Subject: [PATCH] store_metadata_in_osv3: log extra debug info on failure --- .../plugins/exit_store_metadata_in_osv3.py | 13 +++++- tests/plugins/test_store_metadata.py | 46 +++++++++++++++++++ 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/atomic_reactor/plugins/exit_store_metadata_in_osv3.py b/atomic_reactor/plugins/exit_store_metadata_in_osv3.py index 08e546847..d01fc4af3 100644 --- a/atomic_reactor/plugins/exit_store_metadata_in_osv3.py +++ b/atomic_reactor/plugins/exit_store_metadata_in_osv3.py @@ -13,6 +13,7 @@ from osbs.api import OSBS from osbs.conf import Configuration +from osbs.exceptions import OsbsResponseException from atomic_reactor.plugin import ExitPlugin from atomic_reactor.plugins.pre_return_dockerfile import CpDockerfilePlugin @@ -188,10 +189,18 @@ def run(self): "sha256sum": tar_sha256sum, "filename": os.path.basename(tar_path), }) - osbs.set_annotations_on_build(build_id, annotations) + try: + osbs.set_annotations_on_build(build_id, annotations) + except OsbsResponseException: + self.log.debug("annotations: %r", annotations) + raise labels = self.make_labels() if labels: - osbs.update_labels_on_build(build_id, labels) + try: + osbs.update_labels_on_build(build_id, labels) + except OsbsResponseException: + self.log.debug("labels: %r", labels) + raise return {"annotations": annotations, "labels": labels} diff --git a/tests/plugins/test_store_metadata.py b/tests/plugins/test_store_metadata.py index bdcd46e34..f8eb4c8be 100644 --- a/tests/plugins/test_store_metadata.py +++ b/tests/plugins/test_store_metadata.py @@ -17,6 +17,7 @@ from flexmock import flexmock from osbs.api import OSBS import osbs.conf +from osbs.exceptions import OsbsResponseException from atomic_reactor.inner import DockerBuildWorkflow from atomic_reactor.plugin import ExitPluginsRunner from atomic_reactor.plugins.post_rpmqa import PostBuildRPMqaPlugin @@ -290,3 +291,48 @@ def test_missing_koji_build_id(tmpdir): labels = output[StoreMetadataInOSv3Plugin.key]["labels"] assert "koji-build-id" not in labels + +def test_store_metadata_fail_update_annotations(tmpdir, caplog): + workflow = prepare() + + workflow.exit_results = {} + + runner = ExitPluginsRunner( + None, + workflow, + [{ + 'name': StoreMetadataInOSv3Plugin.key, + "args": { + "url": "http://example.com/" + } + }] + ) + (flexmock(OSBS) + .should_receive('set_annotations_on_build') + .and_raise(OsbsResponseException('/', 'failed', 0))) + output = runner.run() + assert 'annotations:' in caplog.text() + + +def test_store_metadata_fail_update_labels(tmpdir, caplog): + workflow = prepare() + + workflow.exit_results = { + KojiPromotePlugin.key: 1234, + } + + runner = ExitPluginsRunner( + None, + workflow, + [{ + 'name': StoreMetadataInOSv3Plugin.key, + "args": { + "url": "http://example.com/" + } + }] + ) + (flexmock(OSBS) + .should_receive('update_labels_on_build') + .and_raise(OsbsResponseException('/', 'failed', 0))) + output = runner.run() + assert 'labels:' in caplog.text()