Skip to content

Commit

Permalink
don't create anymore build_annotations.json
Browse files Browse the repository at this point in the history
* STONEBLD-1057

Signed-off-by: Robert Cerven <[email protected]>
  • Loading branch information
rcerven committed May 16, 2023
1 parent 30ef052 commit 20b2ad5
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 58 deletions.
22 changes: 0 additions & 22 deletions koji_containerbuild/plugins/builder_containerbuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@
from distutils.version import LooseVersion

import dockerfile_parse
import json
import jsonschema
from six import StringIO

# this is present because in some versions of koji, callback functions assume koji.plugin is
# imported
Expand Down Expand Up @@ -94,9 +92,6 @@

METADATA_TAG = "platform:_metadata_"

ANNOTATIONS_FILENAME = 'build_annotations.json'
ANNOTATIONS_FROM_BUILD_RESULTS = ['remote_sources']

DEFAULT_CONF_BINARY_SECTION = "default_binary"
DEFAULT_CONF_SOURCE_SECTION = "default_source"

Expand Down Expand Up @@ -504,20 +499,6 @@ def check_whitelist(self, name, target_info):
raise koji.BuildError("package (container) %s is blocked for tag %s" %
(name, target_info['dest_tag_name']))

def upload_build_results_as_annotations(self, build_results):
task_annotations = {
# For backward compatibility reasons, the values should be JSON-encoded
name: json.dumps(build_results[name])
for name in ANNOTATIONS_FROM_BUILD_RESULTS
if name in build_results
}
if task_annotations:
f = StringIO()
json.dump(task_annotations, f, sort_keys=True, indent=4)
f.seek(0)
incremental_upload(self.session, ANNOTATIONS_FILENAME, f, self.getUploadPath(),
logger=self.logger)

def handle_build_response(self, build_id, platforms: list = None):
try:
return self._handle_build_response(build_id, platforms)
Expand Down Expand Up @@ -569,9 +550,6 @@ def sigint_handler(*args, **kwargs):
has_succeeded = self.osbs().build_has_succeeded(build_id)
build_results = self.osbs().get_build_results(build_id)

if has_succeeded:
self.upload_build_results_as_annotations(build_results)

self.logger.debug("OSBS build finished with status: %s. Build "
"response: %s.", self.osbs().get_build_reason(build_id),
self.osbs().get_build(build_id))
Expand Down
36 changes: 0 additions & 36 deletions tests/test_builder_containerbuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import signal
from textwrap import dedent

import json
import jsonschema
import koji
import pytest
Expand Down Expand Up @@ -1716,41 +1715,6 @@ def test_schema_validation_valid_options_sourcecontainer(self, tmpdir, scratch,

task.handler('target', build_opts)

@pytest.mark.parametrize('build_results', (
{},
{
'remote_sources': [{'name': None, 'url': 'stub_url'}],
'repositories': {'unique': [], 'primary': [], 'floating': []},
'koji-build-id': 1,
},
))
def test_upload_build_results_as_annotations(self, tmpdir, build_results):
def mock_incremental_upload(session, fname, fd, uploadpath, logger=None):
with open(os.path.join(uploadpath, fname), 'w') as f:
data = fd.read()
f.write(data)

builder_containerbuild.incremental_upload = mock_incremental_upload

annotations_file = tmpdir.join('build_annotations.json').strpath
cct = builder_containerbuild.BuildContainerTask(id=1,
method='buildContainer',
params='params',
session='session',
workdir='workdir',
options='options')
flexmock(cct).should_receive('getUploadPath').and_return(tmpdir.strpath)

cct.upload_build_results_as_annotations(build_results)

if not build_results:
assert not os.path.exists(annotations_file)
else:
assert os.path.exists(annotations_file)
with open(annotations_file) as f:
build_annotations = json.load(f)
assert build_annotations == {'remote_sources': '[{"name": null, "url": "stub_url"}]'}

def test_raise_OsbsValidationException(self, tmpdir):
df_content = """\
FROM fedora
Expand Down

0 comments on commit 20b2ad5

Please sign in to comment.