diff options
author | Alexandre Lécuyer <alexandre.lecuyer@corp.ovh.com> | 2017-07-13 15:44:56 +0200 |
---|---|---|
committer | Tim Burke <tim@swiftstack.com> | 2018-03-22 03:02:35 +0000 |
commit | 8d7e245eb599b54d2bcc3c7a652b85987fdb36e1 (patch) | |
tree | d691b5225656ca4d8058b47815ab179551683c28 /swift/obj/auditor.py | |
parent | 9f4910f6b938aa1679571d4787bbdcfa5b5f3a19 (diff) | |
download | swift-8d7e245eb599b54d2bcc3c7a652b85987fdb36e1.tar.gz |
Change object_audit_location_generator() to yield for a single policy.
auditor.py currently relies on POLICY[0] object_audit_location_generator()
to yield an AuditLocation for all policies on the object-server.
The changes in this patch are :
- object_audit_location_generator() yields AuditLocation only for the
requested policy
- audit_all_objects() calls object_audit_location_generator() for each
policy
Closes-Bug: 1534212
Change-Id: Ida92ba0a5e1e486a4f7132c6539460b38c34ec87
Diffstat (limited to 'swift/obj/auditor.py')
-rw-r--r-- | swift/obj/auditor.py | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/swift/obj/auditor.py b/swift/obj/auditor.py index c3245482b..490582d64 100644 --- a/swift/obj/auditor.py +++ b/swift/obj/auditor.py @@ -27,7 +27,7 @@ from eventlet import Timeout from swift.obj import diskfile, replicator from swift.common.utils import ( get_logger, ratelimit_sleep, dump_recon_cache, list_from_csv, listdir, - unlink_paths_older_than, readconf, config_auto_int_value) + unlink_paths_older_than, readconf, config_auto_int_value, round_robin_iter) from swift.common.exceptions import DiskFileQuarantined, DiskFileNotExist,\ DiskFileDeleted, DiskFileExpired from swift.common.daemon import Daemon @@ -120,18 +120,17 @@ class AuditorWorker(object): total_quarantines = 0 total_errors = 0 time_auditing = 0 - # TODO: we should move audit-location generation to the storage policy, - # as we may (conceivably) have a different filesystem layout for each. - # We'd still need to generate the policies to audit from the actual - # directories found on-disk, and have appropriate error reporting if we - # find a directory that doesn't correspond to any known policy. This - # will require a sizable refactor, but currently all diskfile managers - # can find all diskfile locations regardless of policy -- so for now - # just use Policy-0's manager. - all_locs = (self.diskfile_router[POLICIES[0]] + + # get AuditLocations for each policy + loc_generators = [] + for policy in POLICIES: + loc_generators.append( + self.diskfile_router[policy] .object_audit_location_generator( - device_dirs=device_dirs, + policy, device_dirs=device_dirs, auditor_type=self.auditor_type)) + + all_locs = round_robin_iter(loc_generators) for location in all_locs: loop_time = time.time() self.failsafe_object_audit(location) @@ -192,8 +191,11 @@ class AuditorWorker(object): self.logger.info( _('Object audit stats: %s') % json.dumps(self.stats_buckets)) - # Unset remaining partitions to not skip them in the next run - diskfile.clear_auditor_status(self.devices, self.auditor_type) + for policy in POLICIES: + # Unset remaining partitions to not skip them in the next run + self.diskfile_router[policy].clear_auditor_status( + policy, + self.auditor_type) def record_stats(self, obj_size): """ |