path: root/tools/glusterfind/src/
diff options
authorAravinda VK <>2015-06-10 14:47:21 +0530
committerVijay Bellur <>2015-06-12 11:32:59 -0700
commite444c8f454aa791aa723016ceaa66d9eb2971dc0 (patch)
tree3f108cdd89543a8f8c8e23e5e9b2eb6c63a95f40 /tools/glusterfind/src/
parent2e0c8bbe9a04693c270fd383a2a58f3ef87fb898 (diff)
tools/glusterfind: Cleanup session dir after delete
Sessions directories are created in /var/lib/glusterd/glusterfind/<SESSION>/<VOLUME>, only <VOLUME> dir is created since same session name can exists for two volumes. Now cleanup is added, <SESSION> dir will be removed if <SESSION> contains only one Volume. Change-Id: I236393659e63eb98342570e0255739f4adea4491 Signed-off-by: Aravinda VK <> BUG: 1230715 Reviewed-on: Reviewed-on: Tested-by: Gluster Build System <> Reviewed-by: Kotresh HR <>
Diffstat (limited to 'tools/glusterfind/src/')
1 files changed, 10 insertions, 0 deletions
diff --git a/tools/glusterfind/src/ b/tools/glusterfind/src/
index 2e8c2fc9759..e7ba4afa4cb 100644
--- a/tools/glusterfind/src/
+++ b/tools/glusterfind/src/
@@ -14,6 +14,7 @@ import os
import logging
from argparse import ArgumentParser, RawDescriptionHelpFormatter
import urllib
+from errno import ENOTEMPTY
from utils import setup_logger, mkdirp, handle_rm_error
import conf
@@ -78,6 +79,15 @@ def mode_delete(args):
shutil.rmtree(os.path.join(session_dir, args.volume),
+ # If the session contains only this volume, then cleanup the
+ # session directory. If a session contains multiple volumes
+ # then os.rmdir will fail with ENOTEMPTY
+ try:
+ os.rmdir(session_dir)
+ except OSError as e:
+ if not e.errno == ENOTEMPTY:
+ logger.warn("Failed to delete session directory: %s" % e)
def _get_args():
parser = ArgumentParser(formatter_class=RawDescriptionHelpFormatter,