From 7ffcf2453864dbfa49d41326e3d06b80a9ac41ff Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Wed, 6 Jan 2021 16:16:50 -0800 Subject: [PATCH] relinker: Improve logging Use the logger we instantiated in more places. Pass the logger to audit_location_generator so we stand a chance at actually seeing messages about failed mount checks. Change-Id: Idda6512c0a2bc324bdba9ec341ec81d78b7b2f67 --- swift/cli/relinker.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/swift/cli/relinker.py b/swift/cli/relinker.py index 9bf6b52965..c7567c9a8a 100644 --- a/swift/cli/relinker.py +++ b/swift/cli/relinker.py @@ -167,8 +167,8 @@ def relink(swift_dir='/etc/swift', next_part_power = policy.object_ring.next_part_power if not next_part_power or next_part_power == part_power: continue - logging.info('Relinking files for policy %s under %s', - policy.name, devices) + logger.info('Relinking files for policy %s under %s', + policy.name, devices) run = True datadir = diskfile.get_data_dir(policy) @@ -197,7 +197,8 @@ def relink(swift_dir='/etc/swift', hook_post_device=relink_hook_post_device, partitions_filter=relink_partition_filter, hook_post_partition=relink_hook_post_partition, - hashes_filter=relink_hashes_filter) + hashes_filter=relink_hashes_filter, + logger=logger) for fname, _, _ in locations: newfname = replace_partition_in_path(fname, next_part_power) try: @@ -211,7 +212,7 @@ def relink(swift_dir='/etc/swift', if not run: logger.warning("No policy found to increase the partition power.") return 2 - logging.info('Relinked %d diskfiles (%d errors)', relinked, errors) + logger.info('Relinked %d diskfiles (%d errors)', relinked, errors) if errors > 0: return 1 return 0 @@ -234,8 +235,8 @@ def cleanup(swift_dir='/etc/swift', next_part_power = policy.object_ring.next_part_power if not next_part_power or next_part_power != part_power: continue - logging.info('Cleaning up files for policy %s under %s', - policy.name, devices) + logger.info('Cleaning up files for policy %s under %s', + policy.name, devices) run = True datadir = diskfile.get_data_dir(policy) @@ -264,7 +265,8 @@ def cleanup(swift_dir='/etc/swift', hook_post_device=cleanup_hook_post_device, partitions_filter=cleanup_partition_filter, hook_post_partition=cleanup_hook_post_partition, - hashes_filter=cleanup_hashes_filter) + hashes_filter=cleanup_hashes_filter, + logger=logger) for fname, device, partition in locations: expected_fname = replace_partition_in_path(fname, part_power) if fname == expected_fname: @@ -306,7 +308,7 @@ def cleanup(swift_dir='/etc/swift', try: os.remove(fname) cleaned_up += 1 - logging.debug("Removed %s", fname) + logger.debug("Removed %s", fname) except OSError as exc: logger.warning('Error cleaning up %s: %r', fname, exc) errors += 1 @@ -314,7 +316,7 @@ def cleanup(swift_dir='/etc/swift', if not run: logger.warning("No policy found to increase the partition power.") return 2 - logging.info('Cleaned up %d diskfiles (%d errors)', cleaned_up, errors) + logger.info('Cleaned up %d diskfiles (%d errors)', cleaned_up, errors) if errors > 0: return 1 return 0