From 1a87e5eaf54b30c1974ed02aa7e69656d0106c27 Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Mon, 13 Sep 2021 16:05:03 +0200 Subject: [PATCH] mgr/cephadm: Raise errors to properly set a cli status code otherwise `ceph orch host rm` will return 0 Signed-off-by: Sebastian Wagner --- src/pybind/mgr/cephadm/module.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 414013ad5a017..5e4da608a673f 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -1382,13 +1382,15 @@ Then run the following: host_offline = host in self.offline_hosts if host_offline and not offline: - return "{} is offline, please use --offline and --force to remove this host. This can potentially cause data loss".format(host) + raise OrchestratorValidationError( + "{} is offline, please use --offline and --force to remove this host. This can potentially cause data loss".format(host)) if not host_offline and offline: - return "{} is online, please remove host without --offline.".format(host) + raise OrchestratorValidationError( + "{} is online, please remove host without --offline.".format(host)) if offline and not force: - return "Removing an offline host requires --force" + raise OrchestratorValidationError("Removing an offline host requires --force") # check if there are daemons on the host if not force: -- 2.39.5