MemcacheRing raises AttributeError when initialised with default logger
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenStack Object Storage (swift) |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
Since https:/
If no logger is passed to the MemcacheRing constructor it defaults to using logging.getLogger() which does not support the metrics methods (e.g. timing_since) that are called by the memcached_
To reproduce:
```
$ python
Python 3.8.10 (default, Nov 14 2022, 12:59:47)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import swift.common.
>>> m.MemcacheRing([])
<swift.
>>> m.get('x')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'swift.
>>> mr = m.MemcacheRing([])
>>> mr.get('x')
All memcached servers error-limited
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/vagrant/
cache.
AttributeError: 'RootLogger' object has no attribute 'timing_since'
```
To fix, either ensure the default logger is an instance of LogAdapter, or make the decorator calls conditional on logger being of type LogAdpater.
Bah, sorry -- I had pushed up a guarded version at one point [1], but grew less concerned upon realizing the only in-tree place that we'd trip it would be probe tests. One question I've got: how much of a "public" API do we want to make this? We know we have some external tooling that want to use MemcacheRing -- what sorts of tests do we want to make sure we don't accidentally introduce another breaking change?
[1] https:/ /review. opendev. org/c/openstack /swift/ +/869390/ 6/swift/ common/ utils.py