diff options
author | Zuul <zuul@review.opendev.org> | 2022-01-26 12:32:43 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2022-01-26 12:32:43 +0000 |
commit | 46069110102a215955b45b40713b12eabbfc1840 (patch) | |
tree | 5e2058bfa12592354da3dbf4c0d816dcf4afe7aa /swift | |
parent | 793a57d7f96c56c9639a0f5df19ca9ce2fd8e555 (diff) | |
parent | 035d91dce5dfc2fdaf842e9fbeb36684bceab278 (diff) | |
download | swift-46069110102a215955b45b40713b12eabbfc1840.tar.gz |
Merge "Modify log_name in internal clients' pipeline configs"
Diffstat (limited to 'swift')
-rw-r--r-- | swift/cli/container_deleter.py | 7 | ||||
-rw-r--r-- | swift/common/utils.py | 11 | ||||
-rw-r--r-- | swift/container/reconciler.py | 7 | ||||
-rw-r--r-- | swift/container/sharder.py | 7 | ||||
-rw-r--r-- | swift/container/sync.py | 7 | ||||
-rw-r--r-- | swift/obj/expirer.py | 7 |
6 files changed, 33 insertions, 13 deletions
diff --git a/swift/cli/container_deleter.py b/swift/cli/container_deleter.py index 27759e48c..ecd8657d1 100644 --- a/swift/cli/container_deleter.py +++ b/swift/cli/container_deleter.py @@ -133,7 +133,7 @@ def mark_for_deletion(swift, account, container, marker, end_marker, return enqueue_deletes() -def main(): +def main(args=None): parser = argparse.ArgumentParser( description=__doc__, formatter_class=argparse.RawTextHelpFormatter) @@ -156,10 +156,11 @@ def main(): parser.add_argument( '--timestamp', type=Timestamp, default=Timestamp.now(), help='delete all objects as of this time (default: now)') - args = parser.parse_args() + args = parser.parse_args(args) swift = InternalClient( - args.config, 'Swift Container Deleter', args.request_tries) + args.config, 'Swift Container Deleter', args.request_tries, + global_conf={'log_name': 'container-deleter-ic'}) for deleted, marker in mark_for_deletion( swift, args.account, args.container, args.marker, args.end_marker, args.prefix, args.timestamp): diff --git a/swift/common/utils.py b/swift/common/utils.py index 803b1aa19..6a28d53b3 100644 --- a/swift/common/utils.py +++ b/swift/common/utils.py @@ -2387,11 +2387,18 @@ def get_logger(conf, name=None, log_to_console=False, log_route=None, log_statsd_metric_prefix = (empty-string) :param conf: Configuration dict to read settings from - :param name: Name of the logger + :param name: This value is used to populate the ``server`` field in the log + format, as the prefix for statsd messages, and as the default + value for ``log_route``; defaults to the ``log_name`` value in + ``conf``, if it exists, or to 'swift'. :param log_to_console: Add handler which writes to console on stderr :param log_route: Route for the logging, not emitted to the log, just used - to separate logging configurations + to separate logging configurations; defaults to the value + of ``name`` or whatever ``name`` defaults to. This value + is used as the name attribute of the + ``logging.LogAdapter`` that is returned. :param fmt: Override log format + :return: an instance of ``LogAdapter`` """ if not conf: conf = {} diff --git a/swift/container/reconciler.py b/swift/container/reconciler.py index ed677b224..30bc3501c 100644 --- a/swift/container/reconciler.py +++ b/swift/container/reconciler.py @@ -361,6 +361,7 @@ class ContainerReconciler(Daemon): """ Move objects that are in the wrong storage policy. """ + log_route = 'container-reconciler' def __init__(self, conf, logger=None, swift=None): self.conf = conf @@ -372,13 +373,15 @@ class ContainerReconciler(Daemon): conf_path = conf.get('__file__') or \ '/etc/swift/container-reconciler.conf' self.logger = logger or get_logger( - conf, log_route='container-reconciler') + conf, log_route=self.log_route) request_tries = int(conf.get('request_tries') or 3) self.swift = swift or InternalClient( conf_path, 'Swift Container Reconciler', request_tries, - use_replication_network=True) + use_replication_network=True, + global_conf={'log_name': '%s-ic' % conf.get( + 'log_name', self.log_route)}) self.swift_dir = conf.get('swift_dir', '/etc/swift') self.stats = defaultdict(int) self.last_stat_time = time.time() diff --git a/swift/container/sharder.py b/swift/container/sharder.py index eeaa12f2a..db6565fd5 100644 --- a/swift/container/sharder.py +++ b/swift/container/sharder.py @@ -665,9 +665,10 @@ DEFAULT_SHARDER_CONF = vars(ContainerSharderConf()) class ContainerSharder(ContainerSharderConf, ContainerReplicator): """Shards containers.""" + log_route = 'container-sharder' def __init__(self, conf, logger=None): - logger = logger or get_logger(conf, log_route='container-sharder') + logger = logger or get_logger(conf, log_route=self.log_route) ContainerReplicator.__init__(self, conf, logger=logger) ContainerSharderConf.__init__(self, conf) ContainerSharderConf.validate_conf(self) @@ -716,7 +717,9 @@ class ContainerSharder(ContainerSharderConf, ContainerReplicator): 'Swift Container Sharder', request_tries, allow_modify_pipeline=False, - use_replication_network=True) + use_replication_network=True, + global_conf={'log_name': '%s-ic' % conf.get( + 'log_name', self.log_route)}) except (OSError, IOError) as err: if err.errno != errno.ENOENT and \ not str(err).endswith(' not found'): diff --git a/swift/container/sync.py b/swift/container/sync.py index 54acc55f7..4c50bf7bd 100644 --- a/swift/container/sync.py +++ b/swift/container/sync.py @@ -156,13 +156,14 @@ class ContainerSync(Daemon): :param container_ring: If None, the <swift_dir>/container.ring.gz will be loaded. This is overridden by unit tests. """ + log_route = 'container-sync' def __init__(self, conf, container_ring=None, logger=None): #: The dict of configuration values from the [container-sync] section #: of the container-server.conf. self.conf = conf #: Logger to use for container-sync log lines. - self.logger = logger or get_logger(conf, log_route='container-sync') + self.logger = logger or get_logger(conf, log_route=self.log_route) #: Path to the local device mount points. self.devices = conf.get('devices', '/srv/node') #: Indicates whether mount points should be verified as actual mount @@ -241,7 +242,9 @@ class ContainerSync(Daemon): try: self.swift = InternalClient( internal_client_conf, 'Swift Container Sync', request_tries, - use_replication_network=True) + use_replication_network=True, + global_conf={'log_name': '%s-ic' % conf.get( + 'log_name', self.log_route)}) except (OSError, IOError) as err: if err.errno != errno.ENOENT and \ not str(err).endswith(' not found'): diff --git a/swift/obj/expirer.py b/swift/obj/expirer.py index 772b36793..ec53407aa 100644 --- a/swift/obj/expirer.py +++ b/swift/obj/expirer.py @@ -73,10 +73,11 @@ class ObjectExpirer(Daemon): :param conf: The daemon configuration. """ + log_route = 'object-expirer' def __init__(self, conf, logger=None, swift=None): self.conf = conf - self.logger = logger or get_logger(conf, log_route='object-expirer') + self.logger = logger or get_logger(conf, log_route=self.log_route) self.interval = float(conf.get('interval') or 300) self.tasks_per_second = float(conf.get('tasks_per_second', 50.0)) @@ -135,7 +136,9 @@ class ObjectExpirer(Daemon): request_tries = int(self.conf.get('request_tries') or 3) self.swift = swift or InternalClient( self.ic_conf_path, 'Swift Object Expirer', request_tries, - use_replication_network=True) + use_replication_network=True, + global_conf={'log_name': '%s-ic' % self.conf.get( + 'log_name', self.log_route)}) self.processes = int(self.conf.get('processes', 0)) self.process = int(self.conf.get('process', 0)) |