Commit 71eca7c3 authored by Iustin Pop's avatar Iustin Pop
Browse files

Do not walk the whole DATA_DIR on node leave

Since we remove only files from DATA_DIR and not from subdirectories,
let's not walk the entire tree, a simple listdir suffices. Also switch
to utils.RemoveFile from simple os.unlink.

Reviewed-by: imsnah
parent 257f4c0a
......@@ -129,11 +129,11 @@ def LeaveCluster():
"""Cleans up the current node and prepares it to be removed from the cluster.
"""
if os.path.exists(constants.DATA_DIR):
for dirpath, dirnames, filenames in os.walk(constants.DATA_DIR):
if dirpath == constants.DATA_DIR:
for i in filenames:
os.unlink(os.path.join(dirpath, i))
if os.path.isdir(constants.DATA_DIR):
for rel_name in utils.ListVisibleFiles(constants.DATA_DIR):
full_name = os.path.join(constants.DATA_DIR, rel_name)
if os.path.isfile(full_name) and not os.path.islink(full_name):
utils.RemoveFile(full_name)
f = open('/root/.ssh/id_dsa.pub', 'r')
try:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment