~ubuntu-branches/ubuntu/trusty/swift/trusty-updates

« back to all changes in this revision

Viewing changes to bin/swift-account-audit

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2013-01-28 09:40:30 UTC
  • mfrom: (1.2.16)
  • Revision ID: package-import@ubuntu.com-20130128094030-aetz57x2qz9ye2d4
Tags: 1.7.6-0ubuntu1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
 
54
54
class Auditor(object):
55
55
    def __init__(self, swift_dir='/etc/swift', concurrency=50, deep=False,
56
 
                    error_file=None):
 
56
                 error_file=None):
57
57
        self.pool = GreenPool(concurrency)
58
58
        self.object_ring = Ring(os.path.join(swift_dir, ring_name='object'))
59
59
        self.container_ring = \
89
89
            try:
90
90
                if self.deep:
91
91
                    conn = http_connect(node['ip'], node['port'],
92
 
                            node['device'], part, 'GET', path, {})
 
92
                                        node['device'], part, 'GET', path, {})
93
93
                    resp = conn.getresponse()
94
94
                    calc_hash = md5()
95
95
                    chunk = True
101
101
                        self.object_not_found += 1
102
102
                        consistent = False
103
103
                        print '  Bad status GETting object "%s" on %s/%s' \
104
 
                                        % (path, node['ip'], node['device'])
 
104
                            % (path, node['ip'], node['device'])
105
105
                        continue
106
106
                    if resp.getheader('ETag').strip('"') != calc_hash:
107
107
                        self.object_checksum_mismatch += 1
108
108
                        consistent = False
109
109
                        print '  MD5 doesnt match etag for "%s" on %s/%s' \
110
 
                                        % (path, node['ip'], node['device'])
 
110
                            % (path, node['ip'], node['device'])
111
111
                    etags.append(resp.getheader('ETag'))
112
112
                else:
113
113
                    conn = http_connect(node['ip'], node['port'],
118
118
                        self.object_not_found += 1
119
119
                        consistent = False
120
120
                        print '  Bad status HEADing object "%s" on %s/%s' \
121
 
                                        % (path, node['ip'], node['device'])
 
121
                            % (path, node['ip'], node['device'])
122
122
                        continue
123
123
                    etags.append(resp.getheader('ETag'))
124
124
            except Exception:
125
125
                self.object_exceptions += 1
126
126
                consistent = False
127
127
                print '  Exception fetching object "%s" on %s/%s' \
128
 
                                % (path, node['ip'], node['device'])
 
128
                    % (path, node['ip'], node['device'])
129
129
                continue
130
130
        if not etags:
131
131
            consistent = False
136
136
                    consistent = False
137
137
                    self.object_checksum_mismatch += 1
138
138
                    print '  ETag mismatch for "%s" on %s/%s' \
139
 
                                    % (path, node['ip'], node['device'])
 
139
                        % (path, node['ip'], node['device'])
140
140
        if not consistent and self.error_file:
141
141
            print >>open(self.error_file, 'a'), path
142
142
        self.objects_checked += 1
183
183
                    self.container_exceptions += 1
184
184
                    consistent = False
185
185
                    print '  Exception GETting container "%s" on %s/%s' % \
186
 
                                (path, node['ip'], node['device'])
 
186
                        (path, node['ip'], node['device'])
187
187
                    break
188
188
                if results:
189
189
                    marker = results[-1]['name']
196
196
                            self.container_obj_mismatch += 1
197
197
                            consistent = False
198
198
                            print("  Different versions of %s/%s "
199
 
                                  "in container dbs." % \
200
 
                                      (name, obj['name']))
 
199
                                  "in container dbs." % (name, obj['name']))
201
200
                            if (obj['last_modified'] >
202
201
                                    rec_d[obj_name]['last_modified']):
203
202
                                rec_d[obj_name] = obj
204
203
        obj_counts = [int(header['x-container-object-count'])
205
 
                             for header in responses.values()]
 
204
                      for header in responses.values()]
206
205
        if not obj_counts:
207
206
            consistent = False
208
207
            print "  Failed to fetch container %s at all!" % path
266
265
                    marker = results[-1]['name']
267
266
        headers = [resp[0] for resp in responses.values()]
268
267
        cont_counts = [int(header['x-account-container-count'])
269
 
                             for header in headers]
 
268
                       for header in headers]
270
269
        if len(set(cont_counts)) != 1:
271
270
            self.account_container_mismatch += 1
272
271
            consistent = False
276
275
                print "  Max: %s, Min: %s" % (max(cont_counts),
277
276
                                              min(cont_counts))
278
277
        obj_counts = [int(header['x-account-object-count'])
279
 
                             for header in headers]
 
278
                      for header in headers]
280
279
        if len(set(obj_counts)) != 1:
281
280
            self.account_object_mismatch += 1
282
281
            consistent = False