mirror of
https://github.com/xcat2/confluent.git
synced 2025-02-05 13:32:12 +00:00
Improve syncfiles permission denied reporting
When a non-readable file was encountered, confluent would cryptically report rsync failure. Check for the usual culprit, unreadable files if rsync fails. Cause this error to manifest with clearer text.
This commit is contained in:
parent
c93917e4a4
commit
398c8b3a71
@ -90,6 +90,25 @@ def sync_list_to_node(sl, node, suffixes):
|
||||
sshutil.prep_ssh_key('/etc/confluent/ssh/automation')
|
||||
output = subprocess.check_output(
|
||||
['rsync', '-rvL', targdir + '/', 'root@{}:/'.format(node)], timeout=86400)
|
||||
except Exception as e:
|
||||
if 'CalledProcessError' not in repr(e):
|
||||
# https://github.com/eventlet/eventlet/issues/413
|
||||
# for some reason, can't catch the calledprocesserror normally
|
||||
# for this exception, implement a hack workaround
|
||||
raise
|
||||
unreadablefiles = []
|
||||
for root, dirnames, filenames in os.walk(targdir):
|
||||
for filename in filenames:
|
||||
filename = os.path.join(root, filename)
|
||||
try:
|
||||
with open(filename, 'r') as _:
|
||||
pass
|
||||
except OSError as e:
|
||||
unreadablefiles.append(filename.replace(targdir, ''))
|
||||
if unreadablefiles:
|
||||
raise Exception("Syncing failed due to unreadable files: " + ','.join(unreadablefiles))
|
||||
else:
|
||||
raise
|
||||
finally:
|
||||
shutil.rmtree(targdir)
|
||||
return output
|
||||
|
Loading…
x
Reference in New Issue
Block a user