most swift daemons don't honor log_name
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenStack Object Storage (swift) |
Fix Released
|
Low
|
gholt |
Bug Description
the PasteDeploy loadapp/global_conf magic in run_wsgi enables you to set the log_name for each swift server independently. 'object-server' could be 'object-server1' or whatever other name you need to suit your needs.
Most of the daemons give the name of the logger as a string literal when they call get_logger:
self.logger = get_logger(conf, 'object-updater')
In general swift_deamons will use the string literal configured in their __init__ for the NamedLogger tag instead of the value you define in their config section (or DEFAULT) with the log_name key.
The exceptions I can find are the account-reaper, and the db-replicator subclasses. They seem take advantage of the fact that readconf will add a "log_name" key based on the "section_name" if it's not present in the config dict already. If the user sets log_name in the conf - it uses it!
So most calls to utils.get_logger could probably safely drop the literal name kwarg and trust the conf has one in it.
The only exception to that rule would be daemons that call readconf with a section_name of None (AFAIK, only the stats stuff) - they really do need to specify some sort of "default_name" when calling get_logger. In fact the readconf logic in "not section_name" for getting log_name may need it's own bug...
Related branches
- Chuck Thier (community): Approve
-
Diff: 573 lines (+237/-65)7 files modifieddoc/source/deployment_guide.rst (+92/-21)
etc/account-server.conf-sample (+21/-3)
etc/auth-server.conf-sample (+9/-4)
etc/container-server.conf-sample (+18/-3)
etc/object-server.conf-sample (+18/-4)
etc/proxy-server.conf-sample (+49/-8)
swift/common/utils.py (+30/-22)
tags: | added: low-hanging-fruit |
Changed in swift: | |
status: | In Progress → Fix Committed |
Changed in swift: | |
milestone: | none → 1.2.0 |
Changed in swift: | |
status: | Fix Committed → Fix Released |
Then again, it may be better to just fix this in get_logger by treating name as a fallback option only.
In addition to having to update less files, it'd probably make more sense. If those daemons actually intended to override a user specified log_name setting it would have been clearer to force them to write:
conf['log_name'] = 'object-updater'
self.logger = get_logger(conf)
More than likely the intent is to provide a default log_name if conf doesn't define one - i.e. 'log_name' , 'object-updater'))
self.logger = get_logger(conf, conf.get(
But in this case, there's no reason not to just do that for them inside get_logger, similarly to how run_wsgi accepts a default port to use only if there isn't already one specified in the conf.
I grepped around for calls to get_logger - I think it's probably safe for get_logger to just be updated so that name defaults to swift and is only used when the conf is missing the 'log_name' key.