Merge lp:~david-goetz/swift/obj_aud_invalid_hash_trunk into lp:~hudson-openstack/swift/trunk

Proposed by David Goetz
Status: Merged
Approved by: gholt
Approved revision: 235
Merged at revision: 238
Proposed branch: lp:~david-goetz/swift/obj_aud_invalid_hash_trunk
Merge into: lp:~hudson-openstack/swift/trunk
Diff against target: 43 lines (+13/-4)
1 file modified
swift/obj/auditor.py (+13/-4)
To merge this branch: bzr merge lp:~david-goetz/swift/obj_aud_invalid_hash_trunk
Reviewer Review Type Date Requested Status
gholt (community) Approve
Review via email: mp+52461@code.launchpad.net

Description of the change

Fix for object auditor invalidate hashes location bug

To post a comment you must log in.
Revision history for this message
gholt (gholt) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'swift/obj/auditor.py'
2--- swift/obj/auditor.py 2011-02-28 20:20:55 +0000
3+++ swift/obj/auditor.py 2011-03-07 19:26:54 +0000
4@@ -15,9 +15,10 @@
5
6 import os
7 import time
8+import uuid
9+import errno
10 from hashlib import md5
11 from random import random
12-
13 from swift.obj import server as object_server
14 from swift.obj.replicator import invalidate_hash
15 from swift.common.utils import get_logger, renamer, audit_location_generator, \
16@@ -148,10 +149,17 @@
17 self.quarantines += 1
18 self.logger.error(_('ERROR Object %(obj)s failed audit and will '
19 'be quarantined: %(err)s'), {'obj': path, 'err': err})
20- invalidate_hash(os.path.dirname(path))
21+ object_dir = os.path.dirname(path)
22+ invalidate_hash(os.path.dirname(object_dir))
23 renamer_path = os.path.dirname(path)
24- renamer(renamer_path, os.path.join(self.devices, device,
25- 'quarantined', 'objects', os.path.basename(renamer_path)))
26+ to_path = os.path.join(self.devices, device, 'quarantined',
27+ 'objects', os.path.basename(renamer_path))
28+ try:
29+ renamer(renamer_path, to_path)
30+ except OSError, e:
31+ if e.errno == errno.EEXIST:
32+ to_path = "%s-%s" % (to_path, uuid.uuid4().hex)
33+ renamer(renamer_path, to_path)
34 return
35 except Exception:
36 self.errors += 1
37@@ -165,6 +173,7 @@
38
39 def __init__(self, conf, **options):
40 self.conf = conf
41+ self.logger = get_logger(conf, log_route='object-auditor')
42 self.conf_zero_byte_fps = int(conf.get(
43 'zero_byte_files_per_second', 50))
44