From ad4d346371f7df73c06ccd0c70640c3466217901 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 25 Nov 2019 11:17:53 -0600 Subject: [PATCH] mgr/ssh: return err from _run_ceph_daemon Sometimes callers will want to see this. Signed-off-by: Sage Weil --- src/pybind/mgr/ssh/module.py | 21 +++++++++++---------- src/pybind/mgr/ssh/tests/test_ssh.py | 2 +- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/pybind/mgr/ssh/module.py b/src/pybind/mgr/ssh/module.py index 58088bcd2dd..2871f92e1a3 100644 --- a/src/pybind/mgr/ssh/module.py +++ b/src/pybind/mgr/ssh/module.py @@ -602,7 +602,7 @@ class SSHOrchestrator(MgrModule, orchestrator.Orchestrator): raise RuntimeError( 'ceph-daemon exited with an error code: %d, stderr:%s' % ( code, '\n'.join(err))) - return out, code + return out, err, code except Exception as ex: self.log.exception(ex) @@ -689,7 +689,7 @@ class SSHOrchestrator(MgrModule, orchestrator.Orchestrator): @async_map_completion def _refresh_host_services(self, host): - out, code = self._run_ceph_daemon( + out, err, code = self._run_ceph_daemon( host, 'mon', 'ls', [], no_fsid=True) data = json.loads(''.join(out)) self.log.error('refreshed host %s services: %s' % (host, data)) @@ -825,7 +825,7 @@ class SSHOrchestrator(MgrModule, orchestrator.Orchestrator): } name = '%s.%s' % (service_type, service_id) for a in actions[action]: - out, code = self._run_ceph_daemon( + out, err, code = self._run_ceph_daemon( host, name, 'unit', ['--name', name, a], error_ok=True) @@ -856,7 +856,7 @@ class SSHOrchestrator(MgrModule, orchestrator.Orchestrator): if host_info.outdated(self.inventory_cache_timeout) or refresh: self.log.info("refresh stale inventory for '{}'".format(host)) - out, code = self._run_ceph_daemon( + out, err, code = self._run_ceph_daemon( host, 'osd', 'ceph-volume', ['--', 'inventory', '--format=json']) @@ -881,8 +881,9 @@ class SSHOrchestrator(MgrModule, orchestrator.Orchestrator): 'on' if on else 'off'), '--path', '/dev/' + dev, ] - out, code = self._run_ceph_daemon(host, 'osd', 'shell', ['--'] + cmd, - error_ok=True) + out, err, code = self._run_ceph_daemon( + host, 'osd', 'shell', ['--'] + cmd, + error_ok=True) if code: raise RuntimeError( 'Unable to affect %s light for %s:%s. Command: %s' % ( @@ -922,7 +923,7 @@ class SSHOrchestrator(MgrModule, orchestrator.Orchestrator): devices = drive_group.data_devices.paths for device in devices: - out, code = self._run_ceph_daemon( + out, err, code = self._run_ceph_daemon( host, 'osd', 'ceph-volume', [ '--config-and-keyring', '-', @@ -936,7 +937,7 @@ class SSHOrchestrator(MgrModule, orchestrator.Orchestrator): self.log.debug('ceph-volume prepare: %s' % out) # check result - out, code = self._run_ceph_daemon( + out, err, code = self._run_ceph_daemon( host, 'osd', 'ceph-volume', [ '--', @@ -1016,7 +1017,7 @@ class SSHOrchestrator(MgrModule, orchestrator.Orchestrator): 'crash_keyring': crash_keyring, }) - out, code = self._run_ceph_daemon( + out, err, code = self._run_ceph_daemon( host, name, 'deploy', [ '--name', name, @@ -1040,7 +1041,7 @@ class SSHOrchestrator(MgrModule, orchestrator.Orchestrator): """ Remove a daemon """ - out, code = self._run_ceph_daemon( + out, err, code = self._run_ceph_daemon( host, name, 'rm-daemon', ['--name', name]) self.log.debug('_remove_daemon code %s out %s' % (code, out)) diff --git a/src/pybind/mgr/ssh/tests/test_ssh.py b/src/pybind/mgr/ssh/tests/test_ssh.py index af3e6ef5771..868b39b52ae 100644 --- a/src/pybind/mgr/ssh/tests/test_ssh.py +++ b/src/pybind/mgr/ssh/tests/test_ssh.py @@ -27,7 +27,7 @@ TODOs: def _run_ceph_daemon(ret): def foo(*args, **kwargs): - return ret, 0 + return ret, '', 0 return foo def mon_command(*args, **kwargs): -- 2.39.5