ceph/qa/tasks
Kefu Chai d8d44ed156 qa/tasks/ceph_manager: use StringIO for capturing COT output
there are couple factors we should consider when choosing between
BytesIO and StringIO:

- if the producer is producing binary
- if we are expecting binary
- if the layers in between them are doing the decoding/encoding
  automatically.

in our case, the producer is either the ChannelFile instances returned
by paramiko.SSHClient or subprocess.CompletedProcess insances returned
by subprocess.run(). the former are file-like objects opened in "r" mode,
but their contents are decoded with utf-8 when reading if
ChannelFile.FLAG_BINARY is not specified. that's why we always try to
add this flag in orchestra/run.py when collecting the stdout and stderr
from paramiko.SSHClient after executing a command.

back in python2, this works just fine. as we don't differentiate bytes
from str by then.

but in python3, we have to make a decision. in the case of
ceph-objectstore-tool (COT for short), it does not produce binary and
we don't check its output with binary, so, if neither Remote.run() nor
LocalRemote.run() decodes/encodes for us, it's fine.

so it boils down to `copy_to_log()`:

i think we we should respect the consumer's expectation, and only decode
the output if a StringIO is passed in as stdout or stderr.

as we always log the output with logging we could either set
`ChannelFile.FLAG_BINARY` depending on the type of `capture` or not.
if it's not set, paramiko will return str (bytes) on python2, and str on
python3. if it's not set paramiko will return str (bytes) on python2,
and bytes on python3.

if there is non-ASCII in the output, logging will bail fail with
`UnicodeDecodeError` exception. and paramiko throws the same exception
when trying to decode for us if `ChannelFile.FLAG_BINARY` is not
specified.

so to ensure that we always have logging messages no matter if the
producer follows the rule of "use StringIO if you only emit text" or
not, we have to use `ChannelFile.FLAG_BINARY`, and force paramiko
to send us the bytes. but we still have the luxury to use StringIO
and do the decode when the caller asks for str explicitly. that'd save
the pain of using `str.decode()` or `six.ensure_str()` everywhere
even if we can assure that the program does not write binary.

Signed-off-by: Kefu Chai <kchai@redhat.com>
2020-03-09 10:47:48 +08:00
..
cephfs qa: Enable basic mypy support for qa/ directory 2020-03-05 06:54:56 +01:00
mgr Merge PR #33531 into master 2020-03-05 13:20:21 -06:00
tests
util qa: Fix problems detected by mypy 2020-03-05 06:53:31 +01:00
__init__.py
admin_socket.py qa/tasks/admin_socket: get rid of cStringIO for py3 2020-03-04 13:09:17 +08:00
autotest.py qa: Run flake8 on python2 and python3 2019-12-13 09:24:20 +01:00
aver.py
barbican.py qa: Enable flake8 tox and fix failures 2019-12-12 10:21:01 +01:00
blktrace.py qa: get rid of iteritems for python3 compatibility 2019-10-15 11:27:39 +02:00
boto.cfg.template
cbt.py Revert "qa/tasks/cbt: include py2 deps on ubuntu for now" 2020-01-07 09:35:20 +08:00
ceph_client.py qa: get rid of iteritems for python3 compatibility 2019-10-15 11:27:39 +02:00
ceph_deploy.py qa/tasks/ceph_deploy: get rid of cStringIO for py3 2020-03-04 13:09:17 +08:00
ceph_fuse.py qa: add upgrade test for volume upgrade from legacy 2020-03-02 20:27:15 -08:00
ceph_manager.py qa/tasks/ceph_manager: use StringIO for capturing COT output 2020-03-09 10:47:48 +08:00
ceph_objectstore_tool.py qa/tasks/ceph_objectstore_tool: get rid of cStringIO for py3 2020-03-04 13:09:17 +08:00
ceph_test_case.py qa: manage config changes through mons 2020-02-13 07:51:09 -08:00
ceph.conf.template osd/OSDMap: Show health warning if a pool is configured with size 1 2019-11-11 10:36:35 +05:30
ceph.py qa/tasks/ceph.py: quote "<kind>" in command line 2020-03-06 12:17:42 +08:00
cephadm.conf qa/tasks/ceph2 -> cephadm 2019-12-11 19:14:24 -06:00
cephadm.py qa/tasks/cephadm: deploy other monitoring components 2020-03-06 13:32:57 +00:00
cephfs_test_runner.py qa/tasks/cephfs_test_runner: setattr to class not instance 2020-01-09 20:48:23 +08:00
cephfs_upgrade_snap.py
check_counter.py qa: Enable flake8 tox and fix failures 2019-12-12 10:21:01 +01:00
cifs_mount.py
cram.py qa: Run flake8 on python2 and python3 2019-12-13 09:24:20 +01:00
create_verify_lfn_objects.py qa: Enable flake8 tox and fix failures 2019-12-12 10:21:01 +01:00
daemonwatchdog.py qa/tasks/daemonwatchdog: py3 compat 2020-03-04 13:09:16 +08:00
devstack.py
die_on_err.py qa: get rid of iterkeys for py3 compatibility 2019-10-11 18:54:29 +02:00
divergent_priors2.py qa/tasks/divergent_priors2: get rid of cStringIO for py3 2020-03-04 13:09:17 +08:00
divergent_priors.py qa: Enable flake8 tox and fix failures 2019-12-12 10:21:01 +01:00
dnsmasq.py qa: get rid of iteritems for python3 compatibility 2019-10-15 11:27:39 +02:00
dump_stuck.py qa: Enable flake8 tox and fix failures 2019-12-12 10:21:01 +01:00
ec_lost_unfound.py qa: get rid of iterkeys for py3 compatibility 2019-10-11 18:54:29 +02:00
exec_on_cleanup.py qa: Enable flake8 tox and fix failures 2019-12-12 10:21:01 +01:00
filestore_idempotent.py qa: get rid of iterkeys for py3 compatibility 2019-10-11 18:54:29 +02:00
fs.py qa: Enable flake8 tox and fix failures 2019-12-12 10:21:01 +01:00
kclient.py qa: have kclient tests use new mount.ceph functionality 2019-09-20 06:50:43 -04:00
keystone.py qa: Run flake8 on python2 and python3 2019-12-13 09:24:20 +01:00
locktest.py
logrotate.conf
lost_unfound.py qa: get rid of iterkeys for py3 compatibility 2019-10-11 18:54:29 +02:00
manypools.py qa/tasks/manypools: get rid of itervalues for py3 compat 2020-03-04 13:09:17 +08:00
mds_creation_failure.py qa: Enable flake8 tox and fix failures 2019-12-12 10:21:01 +01:00
mds_pre_upgrade.py
mds_thrash.py qa: Fix problems detected by mypy 2020-03-05 06:53:31 +01:00
metadata.yaml
mon_clock_skew_check.py qa: Enable flake8 tox and fix failures 2019-12-12 10:21:01 +01:00
mon_recovery.py qa: get rid of iterkeys for py3 compatibility 2019-10-11 18:54:29 +02:00
mon_thrash.py qa/tasks: fix import module path for py3 compat 2020-03-04 13:09:16 +08:00
multibench.py
netem.py qa/tasks/netem: get rid of cStringIO for py3 2020-03-04 13:09:17 +08:00
object_source_down.py qa: get rid of iterkeys for py3 compatibility 2019-10-11 18:54:29 +02:00
omapbench.py qa/tasks/omapbench: get rid of itervalues for py3 2020-03-04 13:09:16 +08:00
openssl_keys.py
osd_backfill.py qa: get rid of iterkeys for py3 compatibility 2019-10-11 18:54:29 +02:00
osd_failsafe_enospc.py qa/tasks: get rid of cStringIO for py3 2020-03-04 13:09:17 +08:00
osd_max_pg_per_osd.py qa/tasks/osd_max_pg_per_osd: get rid of itervalues for py3 2020-03-04 13:09:16 +08:00
osd_recovery.py qa: get rid of iterkeys for py3 compatibility 2019-10-11 18:54:29 +02:00
peer.py qa: Run flake8 on python2 and python3 2019-12-13 09:24:20 +01:00
peering_speed_test.py
populate_rbd_pool.py qa: get rid of iterkeys for py3 compatibility 2019-10-11 18:54:29 +02:00
qemu.py qa/tasks: use correct NFS service name for EL8 distros 2020-01-17 08:44:43 -05:00
rados.py qa/tasks/rados: get rid of itervalues for py3 2020-03-04 13:09:16 +08:00
radosbench.py qa/tasks/radosbench: fix usage of -O 2020-03-05 07:27:24 -06:00
radosbenchsweep.py qa/tasks/radosbenchsweep: get rid of cStringIO for py3 2020-03-04 13:09:17 +08:00
radosgw_admin_rest.py qa: Enable flake8 tox and fix failures 2019-12-12 10:21:01 +01:00
radosgw_admin.py Merge pull request #30684 from theanalyst/rgw/qa/rgw-admin-user-stats 2020-02-04 17:21:25 +01:00
ragweed.py Merge pull request #32222 from toabctl/qa-flake8-py3 2019-12-24 10:47:07 +08:00
rbd_fio.py qa/tasks/rbd_fio: fio 2.21 -> 3.16 2019-12-16 17:03:06 -06:00
rbd_fsx.py qa: Enable flake8 tox and fix failures 2019-12-12 10:21:01 +01:00
rbd_mirror_thrash.py qa: Enable flake8 tox and fix failures 2019-12-12 10:21:01 +01:00
rbd_mirror.py
rbd.py qa: Fix problems detected by mypy 2020-03-05 06:53:31 +01:00
rebuild_mondb.py qa: get rid of iteritems for python3 compatibility 2019-10-15 11:27:39 +02:00
reg11184.py qa/tasks/reg11184: get rid of cStringIO for py3 2020-03-04 13:09:17 +08:00
rep_lost_unfound_delete.py qa: get rid of iterkeys for py3 compatibility 2019-10-11 18:54:29 +02:00
repair_test.py qa: get rid of iterkeys for py3 compatibility 2019-10-11 18:54:29 +02:00
resolve_stuck_peering.py Merge pull request #30758 from kshtsk/wip-python3-print 2019-10-21 00:34:18 +08:00
restart.py qa: Fix problems detected by mypy 2020-03-05 06:53:31 +01:00
rgw_logsocket.py qa: get rid of iteritems for python3 compatibility 2019-10-15 11:27:39 +02:00
rgw_multi
rgw_multisite_tests.py qa: Enable flake8 tox and fix failures 2019-12-12 10:21:01 +01:00
rgw_multisite.py qa: Enable flake8 tox and fix failures 2019-12-12 10:21:01 +01:00
rgw.py qa: Fix problems detected by mypy 2020-03-05 06:53:31 +01:00
s3a_hadoop.py qa: s3a-hadoop: fix user creation 2020-01-28 10:20:39 -08:00
s3tests_java.py qa/tasks/s3tests_java: move to gradle 6.0.1 2019-12-18 17:04:20 -06:00
s3tests.py Merge pull request #32222 from toabctl/qa-flake8-py3 2019-12-24 10:47:07 +08:00
samba.py qa: Run flake8 on python2 and python3 2019-12-13 09:24:20 +01:00
scrub_test.py qa/tasks/scrub_test: get rid of cStringIO for py3 2020-03-04 13:09:17 +08:00
scrub.py qa/tasks: fix imports for py3 compatibility 2020-03-04 13:09:16 +08:00
systemd.py qa/tasks/systemd: get rid of cStringIO for py3 2020-03-04 13:09:17 +08:00
tempest.py qa: Run flake8 on python2 and python3 2019-12-13 09:24:20 +01:00
teuthology_integration.py
tgt.py qa: get rid of iteritems for python3 compatibility 2019-10-15 11:27:39 +02:00
thrash_pool_snaps.py
thrasher.py qa/tasks: Fixed AttributeError: can't set attribute 2019-11-27 08:30:58 +05:30
thrashosds-health.yaml qa/tasks/thrashosds-health: disable osd_max_markdown behavior 2020-02-28 03:05:45 -06:00
thrashosds.py qa/tasks/thrashosds: fix imports for py3 2020-03-04 13:09:16 +08:00
tox.py qa: Enable flake8 tox and fix failures 2019-12-12 10:21:01 +01:00
userdata_setup.yaml
userdata_teardown.yaml
vault.py rgw: improvements to SSE-KMS with Vault 2019-11-28 09:19:39 +00:00
vstart_runner.py qa: Fix problems detected by mypy 2020-03-05 06:53:31 +01:00
watch_notify_same_primary.py qa/tasks: get rid of cStringIO for py3 2020-03-04 13:09:17 +08:00
watch_notify_stress.py qa/tasks/watch_notify_stress: get rid of itervalues for py3 2020-03-04 13:09:16 +08:00
workunit.py qa: Fix problems detected by mypy 2020-03-05 06:53:31 +01:00