Bug #22816
TypeError: startswith first arg must be bytes or a tuple of bytes, not str in osd.py:375
100%
Description
Target Version: 2.0.0
Python Version: 3.6.4
remoto lib version: 0.0.29
When running ceph-deploy disk list <hostname>
, it throws the following exception:
[ceph_deploy][ERROR ] Traceback (most recent call last): [ceph_deploy][ERROR ] File "/home/cephadm/ceph-deploy/ceph_deploy/util/decorators.py", line 69, in newfunc [ceph_deploy][ERROR ] return f(*a, **kw) [ceph_deploy][ERROR ] File "/home/cephadm/ceph-deploy/ceph_deploy/cli.py", line 164, in _main [ceph_deploy][ERROR ] return args.func(args) [ceph_deploy][ERROR ] File "/home/cephadm/ceph-deploy/ceph_deploy/osd.py", line 436, in disk [ceph_deploy][ERROR ] disk_list(args, cfg) [ceph_deploy][ERROR ] File "/home/cephadm/ceph-deploy/ceph_deploy/osd.py", line 377, in disk_list [ceph_deploy][ERROR ] if line.startswith('Disk /'): [ceph_deploy][ERROR ] TypeError: startswith first arg must be bytes or a tuple of bytes, not str [ceph_deploy][ERROR ]
Editing file osd.py to find out what's going on, I realised that the variable out
, returned by remoto
lib, is a list of bytearray, not string. Thus, the sentence at osd.py:375 (if line.startswith('Disk /'):
) fails because we are trying a string against startswith
.
A simple fix is just replacing 'Disk /'
to b'Disk /'
.
However, fixing that line raises a different exception:
[ceph_deploy][ERROR ] Traceback (most recent call last): [ceph_deploy][ERROR ] File "/home/cephadm/ceph-deploy/ceph_deploy/util/decorators.py", line 69, in newfunc [ceph_deploy][ERROR ] return f(*a, **kw) [ceph_deploy][ERROR ] File "/home/cephadm/ceph-deploy/ceph_deploy/cli.py", line 164, in _main [ceph_deploy][ERROR ] return args.func(args) [ceph_deploy][ERROR ] File "/home/cephadm/ceph-deploy/ceph_deploy/osd.py", line 436, in disk [ceph_deploy][ERROR ] disk_list(args, cfg) [ceph_deploy][ERROR ] File "/home/cephadm/ceph-deploy/ceph_deploy/osd.py", line 376, in disk_list [ceph_deploy][ERROR ] distro.conn.logger(line) [ceph_deploy][ERROR ] TypeError: 'Logger' object is not callable [ceph_deploy][ERROR ]
Which is the line that states: distro.conn.logger(line)
. I believe that sentence should have been instead: LOG.info(line.decode('utf-8'))
. That fixes it.
History
#1 Updated by HacKan CuBa over 5 years ago
#2 Updated by Alfredo Deza over 5 years ago
As discussed in the ceph-deploy PR, a follow up PR will be open for `remoto` to get the string support by default.
#3 Updated by Alfredo Deza over 5 years ago
- Status changed from New to Fix Under Review
Actual logger fix at https://github.com/ceph/ceph-deploy/pull/467
#4 Updated by Alfredo Deza over 5 years ago
- Status changed from Fix Under Review to 15
merged commit c5322ec into master
Setting this to "Pending upstream" so that we can fix the Python 3 issue on github.com/alfredodeza/remoto
#5 Updated by Alfredo Deza over 4 years ago
- Status changed from 15 to Resolved