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 <rcerven@redhat.com>
  • Loading branch information
rcerven committed May 9, 2023
1 parent 30ef052 commit a9dc462
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 56 deletions.
21 changes: 0 additions & 21 deletions koji_containerbuild/plugins/builder_containerbuild.py
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,19 +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:
Expand Down Expand Up @@ -569,9 +551,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
35 changes: 0 additions & 35 deletions tests/test_builder_containerbuild.py
Expand Up @@ -1716,41 +1716,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 a9dc462

Please sign in to comment.