createiso: Skip if buildinstall fails
If the ISO is meant to be bootable but lorax fails, there's no point in creating the ISO as it will not behave as expected. Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1574585 Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
490f079c44
commit
99b6e44a30
@ -95,9 +95,10 @@ def run(config, topdir, has_old):
|
||||
pass
|
||||
|
||||
pkgset_phase = pungi.phases.PkgsetPhase(compose)
|
||||
buildinstall_phase = pungi.phases.BuildinstallPhase(compose)
|
||||
phases = [
|
||||
pungi.phases.InitPhase(compose),
|
||||
pungi.phases.BuildinstallPhase(compose),
|
||||
buildinstall_phase,
|
||||
pkgset_phase,
|
||||
pungi.phases.GatherPhase(compose, pkgset_phase),
|
||||
pungi.phases.ExtraFilesPhase(compose, pkgset_phase),
|
||||
@ -105,7 +106,7 @@ def run(config, topdir, has_old):
|
||||
pungi.phases.OstreeInstallerPhase(compose),
|
||||
pungi.phases.OSTreePhase(compose),
|
||||
pungi.phases.ProductimgPhase(compose, pkgset_phase),
|
||||
pungi.phases.CreateisoPhase(compose),
|
||||
pungi.phases.CreateisoPhase(compose, buildinstall_phase),
|
||||
pungi.phases.LiveImagesPhase(compose),
|
||||
pungi.phases.LiveMediaPhase(compose),
|
||||
pungi.phases.ImageBuildPhase(compose),
|
||||
|
@ -293,7 +293,7 @@ def run_compose(compose, create_latest_link=True, latest_link_status=None):
|
||||
ostree_installer_phase = pungi.phases.OstreeInstallerPhase(compose)
|
||||
ostree_phase = pungi.phases.OSTreePhase(compose)
|
||||
productimg_phase = pungi.phases.ProductimgPhase(compose, pkgset_phase)
|
||||
createiso_phase = pungi.phases.CreateisoPhase(compose)
|
||||
createiso_phase = pungi.phases.CreateisoPhase(compose, buildinstall_phase)
|
||||
liveimages_phase = pungi.phases.LiveImagesPhase(compose)
|
||||
livemedia_phase = pungi.phases.LiveMediaPhase(compose)
|
||||
image_build_phase = pungi.phases.ImageBuildPhase(compose)
|
||||
|
@ -40,9 +40,10 @@ from .. import createiso
|
||||
class CreateisoPhase(PhaseLoggerMixin, PhaseBase):
|
||||
name = "createiso"
|
||||
|
||||
def __init__(self, compose):
|
||||
def __init__(self, compose, buildinstall_phase):
|
||||
super(CreateisoPhase, self).__init__(compose)
|
||||
self.pool = ThreadPool(logger=self.logger)
|
||||
self.bi = buildinstall_phase
|
||||
|
||||
def _find_rpms(self, path):
|
||||
"""Check if there are some RPMs in the path."""
|
||||
@ -88,6 +89,12 @@ class CreateisoPhase(PhaseLoggerMixin, PhaseBase):
|
||||
|
||||
bootable = self._is_bootable(variant, arch)
|
||||
|
||||
if bootable and not self.bi.succeeded(variant, arch):
|
||||
self.logger.warning(
|
||||
'ISO should be bootable, but buildinstall failed. Skipping for %s.%s'
|
||||
% (variant, arch))
|
||||
continue
|
||||
|
||||
split_iso_data = split_iso(self.compose, arch, variant, no_split=bootable,
|
||||
logger=self.logger)
|
||||
disc_count = len(split_iso_data)
|
||||
|
@ -30,7 +30,7 @@ class CreateisoPhaseTest(helpers.PungiTestCase):
|
||||
|
||||
pool = ThreadPool.return_value
|
||||
|
||||
phase = createiso.CreateisoPhase(compose)
|
||||
phase = createiso.CreateisoPhase(compose, mock.Mock())
|
||||
phase.logger = mock.Mock()
|
||||
phase.run()
|
||||
|
||||
@ -49,7 +49,7 @@ class CreateisoPhaseTest(helpers.PungiTestCase):
|
||||
|
||||
pool = ThreadPool.return_value
|
||||
|
||||
phase = createiso.CreateisoPhase(compose)
|
||||
phase = createiso.CreateisoPhase(compose, mock.Mock())
|
||||
phase.logger = mock.Mock()
|
||||
phase.run()
|
||||
|
||||
@ -88,7 +88,7 @@ class CreateisoPhaseTest(helpers.PungiTestCase):
|
||||
|
||||
pool = ThreadPool.return_value
|
||||
|
||||
phase = createiso.CreateisoPhase(compose)
|
||||
phase = createiso.CreateisoPhase(compose, mock.Mock())
|
||||
phase.logger = mock.Mock()
|
||||
phase.run()
|
||||
|
||||
@ -152,7 +152,7 @@ class CreateisoPhaseTest(helpers.PungiTestCase):
|
||||
|
||||
pool = ThreadPool.return_value
|
||||
|
||||
phase = createiso.CreateisoPhase(compose)
|
||||
phase = createiso.CreateisoPhase(compose, mock.Mock())
|
||||
phase.logger = mock.Mock()
|
||||
phase.run()
|
||||
|
||||
@ -209,6 +209,69 @@ class CreateisoPhaseTest(helpers.PungiTestCase):
|
||||
'src'))]
|
||||
)
|
||||
|
||||
@mock.patch('pungi.createiso.write_script')
|
||||
@mock.patch('pungi.phases.createiso.prepare_iso')
|
||||
@mock.patch('pungi.phases.createiso.split_iso')
|
||||
@mock.patch('pungi.phases.createiso.ThreadPool')
|
||||
def test_bootable_but_failed(self, ThreadPool, split_iso, prepare_iso, write_script):
|
||||
compose = helpers.DummyCompose(self.topdir, {
|
||||
'release_short': 'test',
|
||||
'release_version': '1.0',
|
||||
'release_is_layered': False,
|
||||
'buildinstall_method': 'lorax',
|
||||
'bootable': True,
|
||||
'createiso_skip': []
|
||||
})
|
||||
helpers.touch(os.path.join(
|
||||
compose.paths.compose.os_tree('x86_64', compose.variants['Server']),
|
||||
'dummy.rpm'))
|
||||
helpers.touch(os.path.join(
|
||||
compose.paths.compose.os_tree('src', compose.variants['Server']),
|
||||
'dummy.rpm'))
|
||||
disc_data = mock.Mock()
|
||||
split_iso.return_value = [disc_data]
|
||||
prepare_iso.return_value = 'dummy-graft-points'
|
||||
|
||||
pool = ThreadPool.return_value
|
||||
|
||||
mock_bi = mock.Mock(succeeded=lambda v, a: False)
|
||||
|
||||
phase = createiso.CreateisoPhase(compose, mock_bi)
|
||||
phase.logger = mock.Mock()
|
||||
phase.run()
|
||||
|
||||
self.assertItemsEqual(
|
||||
prepare_iso.call_args_list,
|
||||
[mock.call(compose, 'src', compose.variants['Server'],
|
||||
disc_count=1, disc_num=1, split_iso_data=disc_data)])
|
||||
self.assertItemsEqual(
|
||||
split_iso.call_args_list,
|
||||
[mock.call(compose, 'src', compose.variants['Server'], no_split=False, logger=phase.logger)])
|
||||
self.assertEqual(len(pool.add.call_args_list), 1)
|
||||
self.maxDiff = None
|
||||
self.assertItemsEqual(
|
||||
[x[0][0] for x in write_script.call_args_list],
|
||||
[CreateIsoOpts(output_dir='%s/compose/Server/source/iso' % self.topdir,
|
||||
iso_name='image-name',
|
||||
volid='test-1.0 Server.src',
|
||||
graft_points='dummy-graft-points',
|
||||
arch='src',
|
||||
supported=True,
|
||||
jigdo_dir='%s/compose/Server/source/jigdo' % self.topdir,
|
||||
os_tree='%s/compose/Server/source/tree' % self.topdir)])
|
||||
self.assertItemsEqual(
|
||||
pool.queue_put.call_args_list,
|
||||
[mock.call((compose,
|
||||
{'iso_path': '%s/compose/Server/source/iso/image-name' % self.topdir,
|
||||
'bootable': False,
|
||||
'cmd': ['bash', self.topdir + '/work/src/tmp-Server/createiso-image-name.sh'],
|
||||
'label': '',
|
||||
'disc_num': 1,
|
||||
'disc_count': 1},
|
||||
compose.variants['Server'],
|
||||
'src'))]
|
||||
)
|
||||
|
||||
|
||||
class CreateisoThreadTest(helpers.PungiTestCase):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user