From: Michael Fritch Date: Mon, 1 Jun 2020 21:24:35 +0000 (-0600) Subject: mgr/orch: allow '.' char in hostname X-Git-Tag: v16.1.0~2129^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9c14f0d1cdf123ae9216029c9aaef1e09fd81c24;p=ceph.git mgr/orch: allow '.' char in hostname Fixes: https://tracker.ceph.com/issues/45399 Signed-off-by: Michael Fritch --- diff --git a/src/pybind/mgr/cephadm/services/nfs.py b/src/pybind/mgr/cephadm/services/nfs.py index cc786d33ed6a..551c9fe8420c 100644 --- a/src/pybind/mgr/cephadm/services/nfs.py +++ b/src/pybind/mgr/cephadm/services/nfs.py @@ -61,12 +61,13 @@ class NFSService(CephadmService): def config(self, spec): self.mgr._check_pool_exists(spec.pool, spec.service_name()) - logger.info('Saving service %s spec with placement %s' % ( spec.service_name(), spec.placement.pretty_str())) self.mgr.spec_store.save(spec) def create(self, daemon_id, host, spec): + logger.info('Create daemon %s on host %s with spec %s' % ( + daemon_id, host, spec)) return self.mgr._create_daemon('nfs', daemon_id, host) diff --git a/src/pybind/mgr/cephadm/tests/test_spec.py b/src/pybind/mgr/cephadm/tests/test_spec.py index cda89ef02c4c..ea4e8c8f7342 100644 --- a/src/pybind/mgr/cephadm/tests/test_spec.py +++ b/src/pybind/mgr/cephadm/tests/test_spec.py @@ -366,6 +366,31 @@ def test_spec_octopus(): True ), + # https://tracker.ceph.com/issues/45399 + ( + # daemon_id only contains hostname + ServiceSpec( + service_type='mds', + service_id="a", + ), + DaemonDescription( + daemon_type='mds', + daemon_id="a.host1.abc123", + hostname="host1.site", + ), + True + ), + ( + NFSServiceSpec( + service_id="a", + ), + DaemonDescription( + daemon_type='nfs', + daemon_id="a.host1", + hostname="host1.site", + ), + True + ), # https://tracker.ceph.com/issues/45293 ( diff --git a/src/pybind/mgr/orchestrator/_interface.py b/src/pybind/mgr/orchestrator/_interface.py index fd854b04c236..9ebe16752e7f 100644 --- a/src/pybind/mgr/orchestrator/_interface.py +++ b/src/pybind/mgr/orchestrator/_interface.py @@ -1313,19 +1313,22 @@ class DaemonDescription(object): # TODO: can a DaemonDescription exist without a hostname? raise err - if self.hostname == self.daemon_id: - # daemon_id == "hostname" + # use the bare hostname, not the FQDN. + host = self.hostname.split('.')[0] + + if host == self.daemon_id: + # daemon_id == "host" return self.daemon_id - elif self.hostname in self.daemon_id: - # daemon_id == "service_id.hostname" - # daemon_id == "service_id.hostname.random" - pre, post = self.daemon_id.rsplit(self.hostname, 1) + elif host in self.daemon_id: + # daemon_id == "service_id.host" + # daemon_id == "service_id.host.random" + pre, post = self.daemon_id.rsplit(host, 1) if not pre.endswith('.'): - # '.' sep missing at front of hostname + # '.' sep missing at front of host raise err elif post and not post.startswith('.'): - # '.' sep missing at end of hostname + # '.' sep missing at end of host raise err return pre[:-1]