From: Kefu Chai Date: Sun, 28 Jun 2020 11:43:09 +0000 (+0800) Subject: qa/tasks/{ceph,ceph_manager}: drop py2 support X-Git-Tag: v14.2.17~28^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1022920d46bc3976f776b8880f191e4d6738dc0e;p=ceph.git qa/tasks/{ceph,ceph_manager}: drop py2 support Signed-off-by: Kefu Chai --- diff --git a/qa/tasks/ceph.py b/qa/tasks/ceph.py index ae2d587ffd48..5551f274bfaf 100644 --- a/qa/tasks/ceph.py +++ b/qa/tasks/ceph.py @@ -4,6 +4,7 @@ Ceph cluster task. Handle the setup, starting, and clean-up of a Ceph cluster. """ from io import BytesIO +from io import StringIO import argparse import configobj @@ -15,7 +16,6 @@ import json import time import gevent import re -import six import socket from paramiko import SSHException @@ -191,12 +191,12 @@ def ceph_log(ctx, config): testdir = teuthology.get_testdir(ctx) remote_logrotate_conf = '%s/logrotate.ceph-test.conf' % testdir rotate_conf_path = os.path.join(os.path.dirname(__file__), 'logrotate.conf') - with open(rotate_conf_path, 'rb') as f: + with open(rotate_conf_path) as f: conf = "" for daemon, size in daemons.items(): log.info('writing logrotate stanza for {}'.format(daemon)) - conf += six.ensure_str(f.read()).format(daemon_type=daemon, - max_size=size) + conf += f.read().format(daemon_type=daemon, + max_size=size) f.seek(0, 0) for remote in ctx.cluster.remotes.keys(): @@ -319,14 +319,14 @@ def valgrind_post(ctx, config): "/dev/null | sort | uniq", wait=False, check_status=False, - stdout=BytesIO(), + stdout=StringIO(), ) lookup_procs.append((proc, remote)) valgrind_exception = None for (proc, remote) in lookup_procs: proc.wait() - out = six.ensure_str(proc.stdout.getvalue()) + out = proc.stdout.getvalue() for line in out.split('\n'): if line == '': continue @@ -1291,11 +1291,11 @@ def run_daemon(ctx, config, type_): if type_ == 'osd': datadir='/var/lib/ceph/osd/{cluster}-{id}'.format( cluster=cluster_name, id=id_) - osd_uuid = six.ensure_str(teuthology.get_file( + osd_uuid = teuthology.get_file( remote=remote, path=datadir + '/fsid', sudo=True, - )).strip() + ).decode().strip() osd_uuids[id_] = osd_uuid for osd_id in range(len(osd_uuids)): id_ = str(osd_id) diff --git a/qa/tasks/ceph_manager.py b/qa/tasks/ceph_manager.py index f31c4234a969..dfbd315c21df 100644 --- a/qa/tasks/ceph_manager.py +++ b/qa/tasks/ceph_manager.py @@ -13,10 +13,8 @@ import logging import threading import traceback import os -import six -from io import BytesIO -from six import StringIO +from io import BytesIO, StringIO from teuthology import misc as teuthology from tasks.scrub import Scrubber from tasks.util.rados import cmd_erasure_code_profile @@ -273,7 +271,7 @@ class Thrasher: "exp list-pgs failure with status {ret}". format(ret=proc.exitstatus)) - pgs = six.ensure_str(proc.stdout.getvalue()).split('\n')[:-1] + pgs = proc.stdout.getvalue().split('\n')[:-1] if len(pgs) == 0: self.log("No PGs found for osd.{osd}".format(osd=exp_osd)) return @@ -311,7 +309,7 @@ class Thrasher: raise Exception("ceph-objectstore-tool: " "imp list-pgs failure with status {ret}". format(ret=proc.exitstatus)) - pgs = six.ensure_str(proc.stdout.getvalue()).split('\n')[:-1] + pgs = proc.stdout.getvalue().split('\n')[:-1] if pg not in pgs: self.log("Moving pg {pg} from osd.{fosd} to osd.{tosd}". format(pg=pg, fosd=exp_osd, tosd=imp_osd)) @@ -1080,22 +1078,20 @@ class ObjectStoreTool: lines.append(cmd) return "\n".join(lines) - def run(self, options, args, stdin=None, stdout=None): - if stdout is None: - stdout = BytesIO() + def run(self, options, args): self.manager.kill_osd(self.osd) - cmd = self.build_cmd(options, args, stdin) + cmd = self.build_cmd(options, args, None) self.manager.log(cmd) try: proc = self.remote.run(args=['bash', '-e', '-x', '-c', cmd], check_status=False, - stdout=stdout, + stdout=BytesIO(), stderr=BytesIO()) proc.wait() if proc.exitstatus != 0: self.manager.log("failed with " + str(proc.exitstatus)) - error = six.ensure_str(proc.stdout.getvalue()) + " " + \ - six.ensure_str(proc.stderr.getvalue()) + error = proc.stdout.getvalue().decode() + " " + \ + proc.stderr.getvalue().decode() raise Exception(error) finally: if self.do_revive: @@ -1639,7 +1635,7 @@ class CephManager: :param erasure_code_use_overwrites: if true, allow overwrites """ with self.lock: - assert isinstance(pool_name, six.string_types) + assert isinstance(pool_name, str) assert isinstance(pg_num, int) assert pool_name not in self.pools self.log("creating pool_name %s" % (pool_name,)) @@ -1691,7 +1687,7 @@ class CephManager: :param pool_name: Pool to be removed """ with self.lock: - assert isinstance(pool_name, six.string_types) + assert isinstance(pool_name, str) assert pool_name in self.pools self.log("removing pool_name %s" % (pool_name,)) del self.pools[pool_name] @@ -1710,7 +1706,7 @@ class CephManager: Return the number of pgs in the pool specified. """ with self.lock: - assert isinstance(pool_name, six.string_types) + assert isinstance(pool_name, str) if pool_name in self.pools: return self.pools[pool_name] return 0 @@ -1722,8 +1718,8 @@ class CephManager: :returns: property as an int value. """ with self.lock: - assert isinstance(pool_name, six.string_types) - assert isinstance(prop, six.string_types) + assert isinstance(pool_name, str) + assert isinstance(prop, str) output = self.raw_cluster_cmd( 'osd', 'pool', @@ -1741,8 +1737,8 @@ class CephManager: This routine retries if set operation fails. """ with self.lock: - assert isinstance(pool_name, six.string_types) - assert isinstance(prop, six.string_types) + assert isinstance(pool_name, str) + assert isinstance(prop, str) assert isinstance(val, int) tries = 0 while True: @@ -1769,7 +1765,7 @@ class CephManager: Increase the number of pgs in a pool """ with self.lock: - assert isinstance(pool_name, six.string_types) + assert isinstance(pool_name, str) assert isinstance(by, int) assert pool_name in self.pools if self.get_num_creating() > 0: @@ -1789,7 +1785,7 @@ class CephManager: with self.lock: self.log('contract_pool %s by %s min %s' % ( pool_name, str(by), str(min_pgs))) - assert isinstance(pool_name, six.string_types) + assert isinstance(pool_name, str) assert isinstance(by, int) assert pool_name in self.pools if self.get_num_creating() > 0: @@ -1828,7 +1824,7 @@ class CephManager: Set pgpnum property of pool_name pool. """ with self.lock: - assert isinstance(pool_name, six.string_types) + assert isinstance(pool_name, str) assert pool_name in self.pools if not force and self.get_num_creating() > 0: return False