From bc04708990b579a0854cd5f6cdb27f54af08f3ca Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Feb 07 2022 08:59:11 +0000 Subject: PR#3230: hub: whitelist arch-agnostic logs for image tasks Merges #3230 https://pagure.io/koji/pull-request/3230 Fixes: #3229 https://pagure.io/koji/issue/3229 Store image logs per arch --- diff --git a/hub/kojihub.py b/hub/kojihub.py index 6f98161..2f0ea42 100644 --- a/hub/kojihub.py +++ b/hub/kojihub.py @@ -10385,14 +10385,14 @@ def importImageInternal(task_id, build_info, imgdata): logs = [f for f in os.listdir(workpath) if f.endswith('.log')] for logfile in logs: logsrc = joinpath(workpath, logfile) - if tinfo['method'] == 'livemedia': - # multiarch livemedia spins can have log name conflicts, so we - # add the arch to the path + if tinfo['method'] in ('appliance', 'image', 'indirectionimage', 'livecd'): logdir = joinpath(koji.pathinfo.build(build_info), - 'data/logs/image', imgdata['arch']) + 'data/logs/image') else: + # multiarch livemedia (and plugins') spins can have log name conflicts, so we + # add the arch to the path logdir = joinpath(koji.pathinfo.build(build_info), - 'data/logs/image') + 'data/logs/image', imgdata['arch']) koji.ensuredir(logdir) final_path = joinpath(logdir, os.path.basename(logfile)) if os.path.exists(final_path): diff --git a/tests/test_hub/test_complete_image_build.py b/tests/test_hub/test_complete_image_build.py index c6690f6..0d060b2 100644 --- a/tests/test_hub/test_complete_image_build.py +++ b/tests/test_hub/test_complete_image_build.py @@ -101,7 +101,7 @@ class TestCompleteImageBuild(unittest.TestCase): for arch in data: taskdir = koji.pathinfo.task(data[arch]['task_id']) os.makedirs(taskdir) - filenames = data[arch]['files'] + data[arch]['logs'] + filenames = data[arch]['files'] + data[arch]['logs'] for filename in filenames: path = os.path.join(taskdir, filename) with open(path, 'wt', encoding='utf-8') as fp: @@ -117,7 +117,7 @@ class TestCompleteImageBuild(unittest.TestCase): for filename in data[arch]['files']: paths.append(os.path.join(imgdir, filename)) for filename in data[arch]['logs']: - paths.append(os.path.join(logdir, 'image', filename)) + paths.append(os.path.join(logdir, 'image', arch, filename)) # bdir = koji.pathinfo.build(buildinfo) # paths.append(os.path.join(bdir, 'metadata.json')) return paths diff --git a/tests/test_hub/test_import_image_internal.py b/tests/test_hub/test_import_image_internal.py index e0512a8..ba86e26 100644 --- a/tests/test_hub/test_import_image_internal.py +++ b/tests/test_hub/test_import_image_internal.py @@ -109,7 +109,7 @@ class TestImportImageInternal(unittest.TestCase): # Check that the log symlink made it to where it was supposed to. dest = os.readlink(workdir + '/foo.log') dest = os.path.abspath(os.path.join(workdir, dest)) - self.assertEqual(dest, self.tempdir + '/data/logs/image/foo.log') + self.assertEqual(dest, self.tempdir + '/data/logs/image/x86_64/foo.log') # And.. check all the sql statements self.assertEqual(len(cursor.execute.mock_calls), 1)