From 6d719fd923814aba34d126e6845cce3b4efd2437 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 6 Feb 2020 14:31:06 -0600 Subject: [PATCH] mgr/cephadm: factor upgrade failure into helper Signed-off-by: Sage Weil --- src/pybind/mgr/cephadm/module.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 51ab2ccee9b46..3780f10ea46ba 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -467,6 +467,15 @@ class CephadmOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin): del self.health_checks[k] self.set_health_checks(self.health_checks) + def _fail_upgrade(self, alert_id, alert): + self.log.error('Upgrade: Paused due to %s: %s' % (alert_id, + alert['summary'])) + self.upgrade_state['error'] = alert_id + ': ' + alert['summary'] + self.upgrade_state['paused'] = True + self._save_upgrade_state() + self.health_checks[alert_id] = alert + self.set_health_checks(self.health_checks) + def _do_upgrade(self, daemons): # type: (List[orchestrator.ServiceDescription]) -> Optional[AsyncCompletion] if not self.upgrade_state: @@ -565,14 +574,7 @@ class CephadmOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin): mgr_map = self.get('mgr_map') num = len(mgr_map.get('standbys')) if not num: - self.log.warning( - 'Upgrade: No standby mgrs and I need to update the mgr, ' - 'suspending upgrade') - self.upgrade_state['error'] = 'No standby mgrs and mgr.%s ' \ - 'needs to be upgraded' % self.get_mgr_id() - self.upgrade_state['paused'] = True - self._save_upgrade_state() - self.health_checks['UPGRADE_NO_STANDBY_MGR'] = { + self._fail_upgrade('UPGRADE_NO_STANDBY_MGR', { 'severity': 'warning', 'summary': 'Upgrade: Need standby mgr daemon', 'count': 1, @@ -580,8 +582,7 @@ class CephadmOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin): 'The upgrade process needs to upgrade the mgr, ' 'but it needs at least one standby to proceed.', ], - } - self.set_health_checks(self.health_checks) + }) return None self.log.info('Upgrade: there are %d other already-upgraded ' -- 2.39.5