Merge lp:~david-goetz/swift/obj_aud_invalid_hash into lp:swift/1.2

Proposed by David Goetz
Status: Merged
Approved by: Mike Barton
Approved revision: 214
Merged at revision: 214
Proposed branch: lp:~david-goetz/swift/obj_aud_invalid_hash
Merge into: lp:swift/1.2
Diff against target: 36 lines (+12/-4)
1 file modified
swift/obj/auditor.py (+12/-4)
To merge this branch: bzr merge lp:~david-goetz/swift/obj_aud_invalid_hash
Reviewer Review Type Date Requested Status
Swift Core security contacts Pending
Review via email: mp+52273@code.launchpad.net

Description of the change

ObjectAuditor bug with invalidate hash location

To post a comment you must log in.
Revision history for this message
Mike Barton (redbo) wrote :

Looks good enough to merge.

For when this is re-proposed for 1.3... pep8 requires that blank line in the imports, and "renamer_path" and "object_dir" seem to hold the same thing, so you can probably get rid of one.

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-01-21 01:05:44 +0000
3+++ swift/obj/auditor.py 2011-03-05 00:26:18 +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@@ -140,10 +141,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

Subscribers

People subscribed via source and target branches