[image-build] Use subvariants in logging output

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2016-03-17 09:21:35 +01:00
parent f1974d3f03
commit ea7f98ef4e
2 changed files with 30 additions and 14 deletions

View File

@ -142,35 +142,36 @@ class CreateImageBuildThread(WorkerThread):
def process(self, item, num):
compose, cmd = item
variant = cmd["image_conf"]["image-build"]["variant"]
subvariant = cmd["image_conf"]["image-build"].get("subvariant", variant.uid)
try:
self.worker(num, compose, cmd)
self.worker(num, compose, variant, subvariant, cmd)
except Exception as exc:
if not compose.can_fail(cmd["image_conf"]["image-build"]['variant'], '*', 'image-build'):
raise
else:
msg = ('[FAIL] image-build for variant %s failed, but going on anyway.\n%s'
% (cmd['image_conf']['image-build']['variant'], exc))
msg = ('[FAIL] image-build for variant %s (%s) failed, but going on anyway.\n%s'
% (variant.uid, subvariant, exc))
self.pool.log_info(msg)
def worker(self, num, compose, cmd):
def worker(self, num, compose, variant, subvariant, cmd):
arches = cmd["image_conf"]["image-build"]['arches'].split(',')
dash_arches = '-'.join(arches)
log_file = compose.paths.log.log_file(
dash_arches,
"imagebuild-%s-%s-%s" % (dash_arches,
cmd["image_conf"]["image-build"]["variant"],
"imagebuild-%s-%s-%s" % (variant.uid, subvariant,
cmd["image_conf"]["image-build"]['format'].replace(",", "-"))
)
msg = "Creating %s image (arches: %s, variant: %s)" % (cmd["image_conf"]["image-build"]["format"].replace(",", "-"),
dash_arches,
cmd["image_conf"]["image-build"]["variant"])
msg = ("Creating %s image (arches: %s, variant: %s, subvariant: %s)"
% (cmd["image_conf"]["image-build"]["format"].replace(",", "-"),
dash_arches, variant, subvariant))
self.pool.log_info("[BEGIN] %s" % msg)
koji_wrapper = KojiWrapper(compose.conf["koji_profile"])
# writes conf file for koji image-build
self.pool.log_info("Writing image-build config for %s.%s into %s" % (
cmd["image_conf"]["image-build"]["variant"], dash_arches, cmd["conf_file"]))
variant, dash_arches, cmd["conf_file"]))
koji_cmd = koji_wrapper.get_image_build_cmd(cmd["image_conf"],
conf_file_dest=cmd["conf_file"],
scratch=cmd['scratch'])
@ -182,7 +183,8 @@ class CreateImageBuildThread(WorkerThread):
self.pool.log_debug("build-image outputs: %s" % (output))
if output["retcode"] != 0:
self.fail(compose, cmd)
raise RuntimeError("ImageBuild task failed: %s. See %s for more details." % (output["task_id"], log_file))
raise RuntimeError("ImageBuild task failed: %s. See %s for more details."
% (output["task_id"], log_file))
# copy image to images/
image_infos = []
@ -229,8 +231,7 @@ class CreateImageBuildThread(WorkerThread):
img.disc_number = 1 # We don't expect multiple disks
img.disc_count = 1
img.bootable = False
varname = cmd["image_conf"]["image-build"]["variant"].uid
img.subvariant = cmd["image_conf"]["image-build"].get("subvariant", varname)
compose.im.add(variant=varname, arch=image_info['arch'], image=img)
img.subvariant = subvariant
compose.im.add(variant=variant.uid, arch=image_info['arch'], image=img)
self.pool.log_info("[DONE ] %s" % msg)

View File

@ -388,6 +388,7 @@ class TestCreateImageBuildThread(PungiTestCase):
'version': 'Rawhide',
'ksurl': 'git://git.fedorahosted.org/git/spin-kickstarts.git',
'distro': 'Fedora-20',
'subvariant': 'KDE',
}
},
"conf_file": 'amd64,x86_64-Client-Fedora-Docker-Base-docker',
@ -423,6 +424,19 @@ class TestCreateImageBuildThread(PungiTestCase):
with mock.patch('time.sleep'):
t.process((compose, cmd), 1)
self.assertItemsEqual(
koji_wrapper.get_image_build_cmd.call_args_list,
[mock.call(cmd['image_conf'],
conf_file_dest='amd64,x86_64-Client-Fedora-Docker-Base-docker',
scratch=False)]
)
self.assertItemsEqual(
koji_wrapper.run_blocking_cmd.call_args_list,
[mock.call(koji_wrapper.get_image_build_cmd.return_value,
log_file=self.topdir + '/logs/amd64-x86_64/imagebuild-Client-KDE-docker.amd64-x86_64.log')]
)
self.assertItemsEqual(
linker.mock_calls,
[mock.call('/koji/task/1235/Fedora-Docker-Base-20160103.amd64.qcow2',
@ -473,6 +487,7 @@ class TestCreateImageBuildThread(PungiTestCase):
data = image_relative_paths.pop(image.path)
self.assertEqual(data['format'], image.format)
self.assertEqual(data['type'], image.type)
self.assertEqual('KDE', image.subvariant)
self.assertTrue(os.path.isdir(self.topdir + '/compose/Client/amd64/images'))
self.assertTrue(os.path.isdir(self.topdir + '/compose/Client/x86_64/images'))