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
This commit is contained in:
Tomas Kopecek 2022-02-07 09:59:11 +01:00
commit bc04708990
3 changed files with 8 additions and 8 deletions

View file

@ -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
if tinfo['method'] in ('appliance', 'image', 'indirectionimage', 'livecd'):
logdir = joinpath(koji.pathinfo.build(build_info),
'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', imgdata['arch'])
else:
logdir = joinpath(koji.pathinfo.build(build_info),
'data/logs/image')
koji.ensuredir(logdir)
final_path = joinpath(logdir, os.path.basename(logfile))
if os.path.exists(final_path):

View file

@ -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

View file

@ -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)