From 01fb3efdae830e0a5cb5012fe869946daec3a6dc Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Tue, 26 Jun 2018 15:22:07 -0700 Subject: [PATCH] Log unexpected errors when trying to clean up empty dirs Change-Id: I6a0640ba2287dca4eb85e226b809f7b009ef6c17 Related-Change: I2849a757519a30684646f3a6f4467c21e9281707 --- swift/obj/diskfile.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/swift/obj/diskfile.py b/swift/obj/diskfile.py index 714384e355..1320a9e692 100644 --- a/swift/obj/diskfile.py +++ b/swift/obj/diskfile.py @@ -1060,8 +1060,12 @@ class BaseDiskFileManager(object): if not files: # everything got unlinked try: os.rmdir(hsh_path) - except OSError: - pass + except OSError as err: + if err.errno not in (errno.ENOENT, errno.ENOTEMPTY): + self.logger.debug( + 'Error cleaning up empty hash directory %s: %s', + hsh_path, err) + # else, no real harm; pass return results def _update_suffix_hashes(self, hashes, ondisk_info): @@ -1560,12 +1564,15 @@ class BaseDiskFileManager(object): else: try: os.rmdir(suffix_path) - except OSError: + except OSError as err: + if err.errno not in (errno.ENOENT, errno.ENOTEMPTY): + self.logger.debug( + 'Error cleaning up empty suffix directory %s: %s', + suffix_path, err) # cleanup_ondisk_files tries to remove empty hash dirs, # but if it fails, so will we. An empty directory # structure won't cause errors (just slowdown), so we # ignore the exception. - pass if considering_all_suffixes and not have_nonempty_suffix: # There's nothing of interest in the partition, so delete it try: