Project

General

Profile

Bug #22816

TypeError: startswith first arg must be bytes or a tuple of bytes, not str in osd.py:375

Added by HacKan CuBa 10 months ago. Updated 9 months ago.

Status:
Pending Upstream
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
01/26/2018
Due date:
% Done:

100%

Source:
Community (dev)
Tags:
Backport:
Regression:
No
Severity:
3 - minor
Reviewed:
Affected Versions:
ceph-qa-suite:
ceph-deploy

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

#2 Updated by Alfredo Deza 9 months 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 9 months ago

  • Status changed from New to Need Review

#4 Updated by Alfredo Deza 9 months ago

  • Status changed from Need Review to Pending Upstream

merged commit c5322ec into master

Setting this to "Pending upstream" so that we can fix the Python 3 issue on github.com/alfredodeza/remoto

Also available in: Atom PDF