Skip to content

Commit

Permalink
Improve lago collect error handling
Browse files Browse the repository at this point in the history
1. Don't display the entire stack trace on error (but still write
   it to the log). This was achieved by making VMError a subclass of
   LagoException.

2. When ignoring missing files, explain why.

3. Make the error message of ExtractPathNoPathError more informative.

4. Don't propagate errors to the outer log task when ignoring missing
   files, thus avoid false positives on stdout.

Signed-off-by: gbenhaim <[email protected]>
  • Loading branch information
gbenhaim committed Dec 6, 2018
1 parent abb51f7 commit 3210f40
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lago/plugins/vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
LogTask = functools.partial(log_utils.LogTask, logger=LOGGER)


class VMError(Exception):
class VMError(utils.LagoException):
pass


Expand All @@ -58,7 +58,8 @@ class ExtractPathError(VMError):


class ExtractPathNoPathError(VMError):
pass
def __init__(self, err):
super().__init__('Failed to extract files: {}'.format(err))


class LagoVMNotRunningError(utils.LagoUserException):
Expand Down Expand Up @@ -265,11 +266,14 @@ def _extract_paths_scp(self, paths, ignore_nopath):
self.vm.copy_from(
local_path=guest_path,
remote_path=host_path,
propagate_fail=False
propagate_fail=not ignore_nopath
)
except ExtractPathNoPathError as err:
if ignore_nopath:
LOGGER.debug('%s: ignoring', err.args[0])
LOGGER.debug(
'%s: ignoring since ignore_nopath was set to True',
err.args[0]
)
else:
raise

Expand Down Expand Up @@ -417,6 +421,7 @@ def copy_from(
):
with LogTask(
'Copy from %s:%s to %s' % (self.name(), remote_path, local_path),
propagate_fail=propagate_fail
):
try:
with self._scp(propagate_fail=propagate_fail) as scp:
Expand Down

0 comments on commit 3210f40

Please sign in to comment.