From faaa53a89e37283cf3e7c8eb68c3f9d433050141 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sat, 22 Feb 2020 07:33:48 -0600 Subject: [PATCH] mgr/cephadm: catch exceptions when scraping ceph-volume inventory This matches what we do with the background 'cephadm ls'. Signed-off-by: Sage Weil --- src/pybind/mgr/cephadm/module.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 2dd0e03f47539..46ea9a71dbc24 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -1493,10 +1493,16 @@ class CephadmOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin): return None def _refresh_host_devices(self, host): - out, err, code = self._run_cephadm( - host, 'osd', - 'ceph-volume', - ['--', 'inventory', '--format=json']) + try: + out, err, code = self._run_cephadm( + host, 'osd', + 'ceph-volume', + ['--', 'inventory', '--format=json']) + if code: + return 'host %s ceph-volume inventory returned %d: %s' % ( + host, code, err) + except Exception as e: + return 'host %s ceph-volume inventory failed: %s' % (host, e) data = json.loads(''.join(out)) self.log.debug('Refreshed host %s devices: %s' % (host, data)) devices = inventory.Devices.from_json(data) -- 2.39.5