From a3fa9bea9749ffb620593a6b4842dbe67f4c8a89 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 12 Apr 2021 10:17:17 -0400 Subject: [PATCH] mgr/cephadm: allow mgr colo if mgr_standby_modules=false If the standby mgr daemons' modules aren't listening on any ports, then we can schedule multiple on the same host. Note that this may make 'orch ps' output misleading, as ports will be reported for each mgr instance, but only one of them will actually be listening at any one time (if they are behaving, at least!). Treat a mgr port check error as non-fatal. Signed-off-by: Sage Weil (cherry picked from commit 77e0f5b45c6c33c6c4d857bfab3e33ec8d9ed51c) --- src/cephadm/cephadm | 9 ++++++++- src/pybind/mgr/cephadm/services/cephadmservice.py | 12 ++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index 8e86a4a7a0930..0bf5b34bc819a 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -2540,7 +2540,14 @@ def deploy_daemon(ctx, fsid, daemon_type, daemon_id, c, uid, gid, ports = ports or [] if any([port_in_use(ctx, port) for port in ports]): - raise Error("TCP Port(s) '{}' required for {} already in use".format(','.join(map(str, ports)), daemon_type)) + if daemon_type == 'mgr': + # non-fatal for mgr when we are in mgr_standby_modules=false, but we can't + # tell whether that is the case here. + logger.warning( + f"ceph-mgr TCP port(s) {','.join(map(str, ports))} already in use" + ) + else: + raise Error("TCP Port(s) '{}' required for {} already in use".format(','.join(map(str, ports)), daemon_type)) data_dir = get_data_dir(fsid, ctx.data_dir, daemon_type, daemon_id) if reconfig and not os.path.exists(data_dir): diff --git a/src/pybind/mgr/cephadm/services/cephadmservice.py b/src/pybind/mgr/cephadm/services/cephadmservice.py index f5ec2d908c42b..12afdfbcd3463 100644 --- a/src/pybind/mgr/cephadm/services/cephadmservice.py +++ b/src/pybind/mgr/cephadm/services/cephadmservice.py @@ -551,6 +551,18 @@ class MonService(CephService): class MgrService(CephService): TYPE = 'mgr' + def allow_colo(self) -> bool: + if self.mgr.get_ceph_option('mgr_standby_modules'): + # traditional mgr mode: standby daemons' modules listen on + # ports and redirect to the primary. we must not schedule + # multiple mgrs on the same host or else ports will + # conflict. + return False + else: + # standby daemons do nothing, and therefore port conflicts + # are not a concern. + return True + def prepare_create(self, daemon_spec: CephadmDaemonDeploySpec) -> CephadmDaemonDeploySpec: """ Create a new manager instance on a host. -- 2.39.5