From e40fac589ad1fd00031be9c42be942aded56cd6e Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Fri, 20 Jan 2017 15:23:04 -0600 Subject: [PATCH 1/2] Catch MinionError in file.source_list Resolves #38825. --- salt/modules/file.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/salt/modules/file.py b/salt/modules/file.py index 17a4212d7ab8..1bac4d33462d 100644 --- a/salt/modules/file.py +++ b/salt/modules/file.py @@ -55,7 +55,7 @@ import salt.utils.locales import salt.utils.templates import salt.utils.url -from salt.exceptions import CommandExecutionError, SaltInvocationError, get_error_message as _get_error_message +from salt.exceptions import CommandExecutionError, MinionError, SaltInvocationError, get_error_message as _get_error_message log = logging.getLogger(__name__) @@ -3395,9 +3395,14 @@ def source_list(source, source_hash, saltenv): ret = (single_src, single_hash) break elif proto.startswith('http') or proto == 'ftp': - if __salt__['cp.cache_file'](single_src): - ret = (single_src, single_hash) - break + try: + if __salt__['cp.cache_file'](single_src): + ret = (single_src, single_hash) + break + except MinionError as exc: + # Error downloading file. Log the caught exception and + # continue on to the next source. + log.warning(exc.strerror) elif proto == 'file' and os.path.exists(urlparsed_single_src.path): ret = (single_src, single_hash) break From 11a47803cee440c96402d45155d895d5ae71b84b Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Mon, 23 Jan 2017 16:26:45 -0600 Subject: [PATCH 2/2] Use log.exception() instead --- salt/modules/file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/modules/file.py b/salt/modules/file.py index 1bac4d33462d..e24a461a7708 100644 --- a/salt/modules/file.py +++ b/salt/modules/file.py @@ -3402,7 +3402,7 @@ def source_list(source, source_hash, saltenv): except MinionError as exc: # Error downloading file. Log the caught exception and # continue on to the next source. - log.warning(exc.strerror) + log.exception(exc) elif proto == 'file' and os.path.exists(urlparsed_single_src.path): ret = (single_src, single_hash) break