Skip to content

Commit

Permalink
store_metadata_in_osv3: log extra debug info on failure
Browse files Browse the repository at this point in the history
  • Loading branch information
twaugh committed May 22, 2016
1 parent d408c58 commit a15a3d3
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 2 deletions.
13 changes: 11 additions & 2 deletions atomic_reactor/plugins/exit_store_metadata_in_osv3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}
46 changes: 46 additions & 0 deletions tests/plugins/test_store_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()

0 comments on commit a15a3d3

Please sign in to comment.