summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Fritch <mfritch@suse.com>2020-07-21 23:26:43 +0200
committerMichael Fritch <mfritch@suse.com>2020-07-28 23:54:47 +0200
commit2521a7cef1a5ac0d42f26aabe597a89926814152 (patch)
tree3b747de579414ecd2d633d8616922ee03e9b140f
parentmgr/orch: add errno to OrchestratorError (diff)
downloadceph-2521a7cef1a5ac0d42f26aabe597a89926814152.tar.xz
ceph-2521a7cef1a5ac0d42f26aabe597a89926814152.zip
mgr/cephadm: return HandleCommandResult from ok_to_stop
- return output from the result of the ok_to_stop command - log ok-to-stop result during all invocations Signed-off-by: Michael Fritch <mfritch@suse.com>
-rw-r--r--src/pybind/mgr/cephadm/module.py8
-rw-r--r--src/pybind/mgr/cephadm/services/cephadmservice.py25
-rw-r--r--src/pybind/mgr/cephadm/upgrade.py11
3 files changed, 26 insertions, 18 deletions
diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py
index 125fc0ac0f7..e025a209186 100644
--- a/src/pybind/mgr/cephadm/module.py
+++ b/src/pybind/mgr/cephadm/module.py
@@ -1903,8 +1903,12 @@ you may want to run:
r = True
# remove any?
- while remove_daemon_hosts and not self.cephadm_services[daemon_type].ok_to_stop(
- [d.daemon_id for d in remove_daemon_hosts]):
+ def _ok_to_stop(remove_daemon_hosts: Set[orchestrator.DaemonDescription]) -> bool:
+ daemon_ids = [d.daemon_id for d in remove_daemon_hosts]
+ r = self.cephadm_services[daemon_type].ok_to_stop(daemon_ids)
+ return not r.retval
+
+ while remove_daemon_hosts and not _ok_to_stop(remove_daemon_hosts):
# let's find a subset that is ok-to-stop
remove_daemon_hosts.pop()
for d in remove_daemon_hosts:
diff --git a/src/pybind/mgr/cephadm/services/cephadmservice.py b/src/pybind/mgr/cephadm/services/cephadmservice.py
index 6a1bda7c49f..d1ecb6ff498 100644
--- a/src/pybind/mgr/cephadm/services/cephadmservice.py
+++ b/src/pybind/mgr/cephadm/services/cephadmservice.py
@@ -3,7 +3,7 @@ import logging
from abc import ABCMeta, abstractmethod
from typing import TYPE_CHECKING, List, Callable, Any, TypeVar, Generic, Optional, Dict, Any, Tuple
-from mgr_module import MonCommandFailed
+from mgr_module import HandleCommandResult, MonCommandFailed
from ceph.deployment.service_spec import ServiceSpec, RGWSpec
from orchestrator import OrchestratorError, DaemonDescription
@@ -191,23 +191,28 @@ class CephadmService(metaclass=ABCMeta):
- def ok_to_stop(self, daemon_ids: List[str]) -> bool:
+ def ok_to_stop(self, daemon_ids: List[str]) -> HandleCommandResult:
names = [f'{self.TYPE}.{d_id}' for d_id in daemon_ids]
+ out = f'It is presumed safe to stop {names}'
+ err = f'It is NOT safe to stop {names}'
if self.TYPE not in ['mon', 'osd', 'mds']:
- logger.info('Upgrade: It is presumed safe to stop %s' % names)
- return True
+ logger.info(out)
+ return HandleCommandResult(0, out, None)
- ret, out, err = self.mgr.mon_command({
+ r = HandleCommandResult(*self.mgr.mon_command({
'prefix': f'{self.TYPE} ok-to-stop',
'ids': daemon_ids,
- })
+ }))
- if ret:
- logger.info(f'It is NOT safe to stop {names}: {err}')
- return False
+ if r.retval:
+ err = f'{err}: {r.stderr}' if r.stderr else err
+ logger.error(err)
+ return HandleCommandResult(r.retval, r.stdout, err)
- return True
+ out = f'{out}: {r.stdout}' if r.stdout else out
+ logger.info(out)
+ return HandleCommandResult(r.retval, out, r.stderr)
def pre_remove(self, daemon_id: str) -> None:
"""
diff --git a/src/pybind/mgr/cephadm/upgrade.py b/src/pybind/mgr/cephadm/upgrade.py
index f76ba33cce4..5fd031de5cf 100644
--- a/src/pybind/mgr/cephadm/upgrade.py
+++ b/src/pybind/mgr/cephadm/upgrade.py
@@ -126,14 +126,13 @@ class CephadmUpgrade:
if not self.upgrade_state or self.upgrade_state.get('paused'):
return False
- ok = self.mgr.cephadm_services[s.daemon_type].ok_to_stop([s.daemon_id])
+ r = self.mgr.cephadm_services[s.daemon_type].ok_to_stop([s.daemon_id])
- if ok:
- logger.info('Upgrade: It is presumed safe to stop %s.%s' %
- (s.daemon_type, s.daemon_id))
+ if not r.retval:
+ logger.info(f'Upgrade: {r.stdout}')
return True
- logger.info('Upgrade: It is NOT safe to stop %s.%s' %
- (s.daemon_type, s.daemon_id))
+ logger.error('Upgrade: {r.stderr}')
+
time.sleep(15)
tries -= 1
return False