mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-22 18:00:35 +00:00
Preserve stacktraces when reraising exceptions
This commit is contained in:
parent
b67b174eb5
commit
ac7e32d35e
7 changed files with 13 additions and 13 deletions
|
@ -92,13 +92,13 @@ class AbstractPartitionMap(FSMProxy):
|
|||
if partition.fsm.current not in ['mapped', 'formatted']:
|
||||
raise PartitionError('kpartx did not map partition #' + str(idx + 1))
|
||||
|
||||
except PartitionError as e:
|
||||
except PartitionError:
|
||||
# Revert any mapping and reraise the error
|
||||
for partition in self.partitions:
|
||||
if not partition.fsm.can('unmap'):
|
||||
partition.unmap()
|
||||
log_check_call(['kpartx', '-ds', volume.device_path])
|
||||
raise e
|
||||
raise
|
||||
|
||||
def unmap(self, volume):
|
||||
"""Unmaps the partition
|
||||
|
|
|
@ -138,5 +138,5 @@ def run(manifest, debug=False, pause_on_error=False, dry_run=False, check_contin
|
|||
# Run the rollback tasklist
|
||||
rollback_tasklist.run(info=bootstrap_info, dry_run=dry_run)
|
||||
log.info('Successfully completed rollback')
|
||||
raise e
|
||||
raise
|
||||
return bootstrap_info
|
||||
|
|
|
@ -164,7 +164,7 @@ class AptUpgrade(Task):
|
|||
'This can sometimes occur when package retrieval times out or a package extraction failed. '
|
||||
'apt might succeed if you try bootstrapping again.')
|
||||
logging.getLogger(__name__).warn(msg)
|
||||
raise e
|
||||
raise
|
||||
|
||||
|
||||
class PurgeUnusedPackages(Task):
|
||||
|
|
|
@ -76,10 +76,10 @@ class InstallGrub_1_99(Task):
|
|||
# Install grub
|
||||
log_check_call(['chroot', info.root, 'grub-install', device_path])
|
||||
log_check_call(['chroot', info.root, 'update-grub'])
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
if isinstance(info.volume, LoopbackVolume):
|
||||
remount(info.volume, unlink_fn)
|
||||
raise e
|
||||
raise
|
||||
|
||||
if isinstance(info.volume, LoopbackVolume):
|
||||
remount(info.volume, unlink_fn)
|
||||
|
|
|
@ -69,7 +69,7 @@ class InstallPackages(Task):
|
|||
'This can sometimes occur when package retrieval times out or a package extraction failed. '
|
||||
'apt might succeed if you try bootstrapping again.')
|
||||
logging.getLogger(__name__).warn(msg)
|
||||
raise e
|
||||
raise
|
||||
|
||||
@classmethod
|
||||
def install_local(cls, info, local_packages):
|
||||
|
|
|
@ -110,16 +110,16 @@ class RemoteBuildServer(BuildServer):
|
|||
try:
|
||||
self.connection.ping()
|
||||
break
|
||||
except (Pyro4.errors.ConnectionClosedError, Pyro4.errors.CommunicationError) as e:
|
||||
except (Pyro4.errors.ConnectionClosedError, Pyro4.errors.CommunicationError):
|
||||
if remaining_retries > 0:
|
||||
remaining_retries -= 1
|
||||
from time import sleep
|
||||
sleep(2)
|
||||
else:
|
||||
raise e
|
||||
except (Exception, KeyboardInterrupt) as e:
|
||||
raise
|
||||
except (Exception, KeyboardInterrupt):
|
||||
self.ssh_process.terminate()
|
||||
raise e
|
||||
raise
|
||||
return self.connection
|
||||
|
||||
def disconnect(self):
|
||||
|
|
|
@ -54,11 +54,11 @@ class BootableManifest(object):
|
|||
self.image.open()
|
||||
self.instance = self.image.get_instance()
|
||||
self.instance.up()
|
||||
except (Exception, KeyboardInterrupt) as e:
|
||||
except (Exception, KeyboardInterrupt):
|
||||
if hasattr(self, 'image'):
|
||||
self.image.close()
|
||||
self.image.destroy()
|
||||
raise e
|
||||
raise
|
||||
return self.instance
|
||||
|
||||
def __exit__(self, type, value, traceback):
|
||||
|
|
Loading…
Add table
Reference in a new issue