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