From e9f49a462f9a75c6d86187b64b338e14155d2980 Mon Sep 17 00:00:00 2001 From: John Spray Date: Wed, 30 Oct 2013 17:12:58 +0000 Subject: [PATCH] Improve error reporting from verify_files Make it similar to what verify_env already does, so that we tell people exactly which path was a problem. I hit this while running salt-master in a non-standard configuration, and the change makes it easier to hunt down which path is wrong in a config. --- salt/utils/verify.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/salt/utils/verify.py b/salt/utils/verify.py index cf39f8d7a4..fc0dc204fc 100644 --- a/salt/utils/verify.py +++ b/salt/utils/verify.py @@ -161,11 +161,17 @@ def verify_files(files, user): sys.exit(2) for fn_ in files: dirname = os.path.dirname(fn_) - if not os.path.isdir(dirname): - os.makedirs(dirname) - if not os.path.isfile(fn_): - with salt.utils.fopen(fn_, 'w+') as fp_: - fp_.write('') + try: + if not os.path.isdir(dirname): + os.makedirs(dirname) + if not os.path.isfile(fn_): + with salt.utils.fopen(fn_, 'w+') as fp_: + fp_.write('') + except OSError as err: + msg = 'Failed to create path "{0}" - {1}\n' + sys.stderr.write(msg.format(fn_, err)) + sys.exit(err.errno) + stats = os.stat(fn_) if uid != stats.st_uid: try: