diff options
author | Mahati Chamarthy <mahati.chamarthy@gmail.com> | 2016-06-20 15:56:15 +0530 |
---|---|---|
committer | Mahati Chamarthy <mahati.chamarthy@gmail.com> | 2016-11-16 10:11:30 +0530 |
commit | 321bb9145f9e2e184994e5d0cf78c62b6043112c (patch) | |
tree | 61dea891261317a49a82106b33e5d843a3be7bc0 /swift/common/db_replicator.py | |
parent | d7920324f63d27587fe4648b43d2394a35f025d7 (diff) | |
download | swift-321bb9145f9e2e184994e5d0cf78c62b6043112c.tar.gz |
remove empty db hash and suffix directories
If a db gets quarantined we may fail to cleanup an empty suffix dir or
a hash dir.
Change-Id: I721fa5fe9a7ae22eead8d5141f93e116847ca058
Closes-Bug: #1583719
Diffstat (limited to 'swift/common/db_replicator.py')
-rw-r--r-- | swift/common/db_replicator.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/swift/common/db_replicator.py b/swift/common/db_replicator.py index 7115a8afe..7d1bb7afa 100644 --- a/swift/common/db_replicator.py +++ b/swift/common/db_replicator.py @@ -89,11 +89,15 @@ def roundrobin_datadirs(datadirs): suffixes = os.listdir(part_dir) if not suffixes: os.rmdir(part_dir) + continue for suffix in suffixes: suff_dir = os.path.join(part_dir, suffix) if not os.path.isdir(suff_dir): continue hashes = os.listdir(suff_dir) + if not hashes: + os.rmdir(suff_dir) + continue for hsh in hashes: hash_dir = os.path.join(suff_dir, hsh) if not os.path.isdir(hash_dir): @@ -101,6 +105,15 @@ def roundrobin_datadirs(datadirs): object_file = os.path.join(hash_dir, hsh + '.db') if os.path.exists(object_file): yield (partition, object_file, node_id) + else: + try: + os.rmdir(hash_dir) + except OSError as e: + if e.errno is not errno.ENOTEMPTY: + raise + # remove empty partitions after the above directory walk + if not suffixes: + os.rmdir(part_dir) its = [walk_datadir(datadir, node_id) for datadir, node_id in datadirs] while its: |