Ensure all phases are stopped

If a phase is started successfully, it needs to be stopped as well. In
most cases when `stop` is called immediately after `start`, this is not
a problem.

Only when something else happens while a phase is runnning and this
something fails, Pungi will deadlock and never exit. This something
could be another phase or just main thread raising an exception.

Fixes: #625
Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2017-05-29 09:56:23 +02:00
parent 8c237b78c2
commit 247a1a71ba
3 changed files with 85 additions and 30 deletions

View file

@ -354,25 +354,25 @@ def run_compose(compose, create_latest_link=True, latest_link_status=None):
pkgset_phase.start()
pkgset_phase.stop()
# BUILDINSTALL phase - start
# BUILDINSTALL phase - start, we can run gathering, extra files and
# createrepo while buildinstall is in progress.
buildinstall_phase.start()
# GATHER phase
gather_phase.start()
gather_phase.stop()
# If any of the following three phases fail, we must ensure that
# buildinstall is stopped. Otherwise the whole process will hang.
try:
gather_phase.start()
gather_phase.stop()
# EXTRA_FILES phase
extrafiles_phase.start()
extrafiles_phase.stop()
extrafiles_phase.start()
extrafiles_phase.stop()
# CREATEREPO phase
createrepo_phase.start()
createrepo_phase.stop()
createrepo_phase.start()
createrepo_phase.stop()
finally:
buildinstall_phase.stop()
# BUILDINSTALL phase
# must finish before PRODUCTIMG
# must finish before CREATEISO
buildinstall_phase.stop()
if not buildinstall_phase.skip():
buildinstall_phase.copy_files()
@ -396,20 +396,12 @@ def run_compose(compose, create_latest_link=True, latest_link_status=None):
timestamp = pungi.metadata.write_discinfo(compose, arch, variant)
pungi.metadata.write_media_repo(compose, arch, variant, timestamp)
# CREATEISO and LIVEIMAGES phases
createiso_phase.start()
liveimages_phase.start()
image_build_phase.start()
livemedia_phase.start()
ostree_installer_phase.start()
osbs_phase.start()
createiso_phase.stop()
liveimages_phase.stop()
image_build_phase.stop()
livemedia_phase.stop()
ostree_installer_phase.stop()
osbs_phase.stop()
# Start all phases for image artifacts
pungi.phases.run_all([createiso_phase,
liveimages_phase,
image_build_phase,
ostree_installer_phase,
osbs_phase])
image_checksum_phase.start()
image_checksum_phase.stop()