]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/mgr/cephadm: rename variables to avoid name reuse
authorKefu Chai <kchai@redhat.com>
Tue, 19 Jan 2021 09:20:29 +0000 (17:20 +0800)
committerSebastian Wagner <sebastian.wagner@suse.com>
Fri, 29 Jan 2021 12:42:38 +0000 (13:42 +0100)
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 <kchai@redhat.com>
(cherry picked from commit 53415832cdbef94d2f3777e8f3abb8560b15323e)

src/pybind/mgr/cephadm/module.py
src/pybind/mgr/cephadm/services/osd.py
src/pybind/mgr/cephadm/upgrade.py

index f8e759dabc2b1dfb5b01daf4e8a978e38d8ec5b4..0d74aac71380cec5954815c4c4d6a0bcae125bef 100644 (file)
@@ -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}")
 
index 5516b575273ba461a49e34724f6914a9a4ab7a3e..0d88b52fe0742c688961f5799bf2743f0f91814e 100644 (file)
@@ -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:
index a1356b8e749b8f5e3fbc38caa5e0b3e67ba771ac..f9d1ba11ec98c659b0b19a090fb9c2078f77cb6d 100644 (file)
@@ -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: