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
=== modified file 'swift/obj/auditor.py'
--- swift/obj/auditor.py 2011-02-28 20:20:55 +0000
+++ swift/obj/auditor.py 2011-03-07 19:26:54 +0000
@@ -15,9 +15,10 @@
1515
16import os16import os
17import time17import time
18import uuid
19import errno
18from hashlib import md520from hashlib import md5
19from random import random21from random import random
20
21from swift.obj import server as object_server22from swift.obj import server as object_server
22from swift.obj.replicator import invalidate_hash23from swift.obj.replicator import invalidate_hash
23from swift.common.utils import get_logger, renamer, audit_location_generator, \24from swift.common.utils import get_logger, renamer, audit_location_generator, \
@@ -148,10 +149,17 @@
148 self.quarantines += 1149 self.quarantines += 1
149 self.logger.error(_('ERROR Object %(obj)s failed audit and will '150 self.logger.error(_('ERROR Object %(obj)s failed audit and will '
150 'be quarantined: %(err)s'), {'obj': path, 'err': err})151 'be quarantined: %(err)s'), {'obj': path, 'err': err})
151 invalidate_hash(os.path.dirname(path))152 object_dir = os.path.dirname(path)
153 invalidate_hash(os.path.dirname(object_dir))
152 renamer_path = os.path.dirname(path)154 renamer_path = os.path.dirname(path)
153 renamer(renamer_path, os.path.join(self.devices, device,155 to_path = os.path.join(self.devices, device, 'quarantined',
154 'quarantined', 'objects', os.path.basename(renamer_path)))156 'objects', os.path.basename(renamer_path))
157 try:
158 renamer(renamer_path, to_path)
159 except OSError, e:
160 if e.errno == errno.EEXIST:
161 to_path = "%s-%s" % (to_path, uuid.uuid4().hex)
162 renamer(renamer_path, to_path)
155 return163 return
156 except Exception:164 except Exception:
157 self.errors += 1165 self.errors += 1
@@ -165,6 +173,7 @@
165173
166 def __init__(self, conf, **options):174 def __init__(self, conf, **options):
167 self.conf = conf175 self.conf = conf
176 self.logger = get_logger(conf, log_route='object-auditor')
168 self.conf_zero_byte_fps = int(conf.get(177 self.conf_zero_byte_fps = int(conf.get(
169 'zero_byte_files_per_second', 50))178 'zero_byte_files_per_second', 50))
170179