From: Kefu Chai Date: Tue, 19 Jan 2021 09:20:29 +0000 (+0800) Subject: pybind/mgr/cephadm: rename variables to avoid name reuse X-Git-Tag: v16.2.0~230^2~22 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=586ca46890a2e67db84267b49f077213013e627c;p=ceph.git pybind/mgr/cephadm: rename variables to avoid name reuse to applease mypy, otherwise, for instance, "err" would be reused for holding the return value of self.mgr.check_mon_command(...) Signed-off-by: Kefu Chai (cherry picked from commit 53415832cdbef94d2f3777e8f3abb8560b15323e) --- diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index f8e759dabc2..0d74aac7138 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -1333,10 +1333,10 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule, raise OrchestratorError(msg, errno=rc) # call the host-maintenance function - out, _err, _code = CephadmServe(self)._run_cephadm(hostname, cephadmNoImage, "host-maintenance", - ["enter"], - error_ok=True) - if out: + _out, _err, _code = CephadmServe(self)._run_cephadm(hostname, cephadmNoImage, "host-maintenance", + ["enter"], + error_ok=True) + if _out: raise OrchestratorError( f"Failed to place {hostname} into maintenance for cluster {self._cluster_fsid}") @@ -1384,10 +1384,10 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule, if tgt_host['status'] != "maintenance": raise OrchestratorError(f"Host {hostname} is not in maintenance mode") - out, _err, _code = CephadmServe(self)._run_cephadm(hostname, cephadmNoImage, 'host-maintenance', - ['exit'], - error_ok=True) - if out: + outs, errs, _code = CephadmServe(self)._run_cephadm(hostname, cephadmNoImage, 'host-maintenance', + ['exit'], + error_ok=True) + if outs: raise OrchestratorError( f"Failed to exit maintenance state for host {hostname}, cluster {self._cluster_fsid}") diff --git a/src/pybind/mgr/cephadm/services/osd.py b/src/pybind/mgr/cephadm/services/osd.py index 5516b575273..0d88b52fe07 100644 --- a/src/pybind/mgr/cephadm/services/osd.py +++ b/src/pybind/mgr/cephadm/services/osd.py @@ -318,11 +318,10 @@ class RemoveUtil(object): 'format': 'json' }) try: - ret = json.loads(out) + return json.loads(out) except ValueError: logger.exception(f'Cannot decode JSON: \'{out}\'') return {} - return ret def get_pg_count(self, osd_id: int, osd_df: Optional[dict] = None) -> int: if not osd_df: diff --git a/src/pybind/mgr/cephadm/upgrade.py b/src/pybind/mgr/cephadm/upgrade.py index a1356b8e749..f9d1ba11ec9 100644 --- a/src/pybind/mgr/cephadm/upgrade.py +++ b/src/pybind/mgr/cephadm/upgrade.py @@ -300,13 +300,13 @@ class CephadmUpgrade: continue # make sure host has latest container image - out, err, code = CephadmServe(self.mgr)._run_cephadm( + out, errs, code = CephadmServe(self.mgr)._run_cephadm( d.hostname, '', 'inspect-image', [], image=target_image, no_fsid=True, error_ok=True) if code or json.loads(''.join(out)).get('image_id') != target_id: logger.info('Upgrade: Pulling %s on %s' % (target_image, d.hostname)) - out, err, code = CephadmServe(self.mgr)._run_cephadm( + out, errs, code = CephadmServe(self.mgr)._run_cephadm( d.hostname, '', 'pull', [], image=target_image, no_fsid=True, error_ok=True) if code: