From 3cbebf37a627154b9d4a7d67d53d5bf0d8639fc7 Mon Sep 17 00:00:00 2001 From: Michael Fritch Date: Mon, 27 Apr 2020 11:44:44 -0600 Subject: [PATCH] mgr/orch: match last occurance of hostname in service_id The RGW realm/zone might have a substr that matches the hostname Fixes: https://tracker.ceph.com/issues/45294 Signed-off-by: Michael Fritch --- src/pybind/mgr/cephadm/tests/test_spec.py | 15 +++++++++++++++ src/pybind/mgr/orchestrator/_interface.py | 19 +++---------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/pybind/mgr/cephadm/tests/test_spec.py b/src/pybind/mgr/cephadm/tests/test_spec.py index 3d0826391e0..530dae1fb5a 100644 --- a/src/pybind/mgr/cephadm/tests/test_spec.py +++ b/src/pybind/mgr/cephadm/tests/test_spec.py @@ -282,6 +282,21 @@ def test_spec_octopus(): ), False ), + ( + # zone contains hostname + # https://tracker.ceph.com/issues/45294 + RGWSpec( + rgw_realm="default.rgw.realm", + rgw_zone="ceph.001", + subcluster='1', + ), + DaemonDescription( + daemon_type='rgw', + daemon_id="default.rgw.realm.ceph.001.1.ceph.001.ytywjo", + hostname="ceph.001", + ), + True + ), # https://tracker.ceph.com/issues/45293 ( diff --git a/src/pybind/mgr/orchestrator/_interface.py b/src/pybind/mgr/orchestrator/_interface.py index ee482adee61..0e18882e7fe 100644 --- a/src/pybind/mgr/orchestrator/_interface.py +++ b/src/pybind/mgr/orchestrator/_interface.py @@ -1304,25 +1304,12 @@ class DaemonDescription(object): if m: return m.group(1) - if self.daemon_type == 'rgw': - if self.hostname and self.hostname in self.daemon_id: - pre, post_ = self.daemon_id.split(self.hostname) - return pre[:-1] - else: - # daemon_id == "realm.zone.host.random" - v = self.daemon_id.split('.') - if len(v) == 4: - return '.'.join(v[0:2]) - # subcluster or fqdn? undecidable. - raise OrchestratorError(f"DaemonDescription: Cannot calculate service_id: {v}") - - if self.daemon_type in ['mds', 'nfs', 'iscsi']: - service_id = _match() - if service_id: - return service_id raise OrchestratorError("DaemonDescription: Cannot calculate service_id: " \ f"daemon_id='{self.daemon_id}' hostname='{self.hostname}'") + if self.daemon_type in ['mds', 'nfs', 'iscsi', 'rgw']: + return _match() + return self.daemon_id def service_name(self): -- 2.39.5