diff options
Diffstat (limited to 'tools/glusterfind/src/nodeagent.py')
-rw-r--r-- | tools/glusterfind/src/nodeagent.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tools/glusterfind/src/nodeagent.py b/tools/glusterfind/src/nodeagent.py index 2e8c2fc9759..e7ba4afa4cb 100644 --- a/tools/glusterfind/src/nodeagent.py +++ b/tools/glusterfind/src/nodeagent.py @@ -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), onerror=handle_rm_error) + # 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, |