True
),
+ # https://tracker.ceph.com/issues/45617
+ (
+ # daemon_id does not contain hostname
+ ServiceSpec(
+ service_type='mds',
+ service_id="a",
+ ),
+ DaemonDescription(
+ daemon_type='mds',
+ daemon_id="a",
+ hostname="host1",
+ ),
+ True
+ ),
+ (
+ # daemon_id only contains hostname
+ ServiceSpec(
+ service_type='mds',
+ service_id="host1",
+ ),
+ DaemonDescription(
+ daemon_type='mds',
+ daemon_id="host1",
+ hostname="host1",
+ ),
+ True
+ ),
+
+
# https://tracker.ceph.com/issues/45293
(
NFSServiceSpec(
def service_id(self):
def _match():
- if self.hostname:
+ err = OrchestratorError("DaemonDescription: Cannot calculate service_id: " \
+ f"daemon_id='{self.daemon_id}' hostname='{self.hostname}'")
+
+ if not self.hostname:
+ # TODO: can a DaemonDescription exist without a hostname?
+ raise err
+
+ if self.hostname == self.daemon_id:
+ # daemon_id == "hostname"
+ return self.daemon_id
+
+ elif self.hostname in self.daemon_id:
# daemon_id == "service_id.hostname"
# daemon_id == "service_id.hostname.random"
- p = re.compile(r'(.*)\.%s(\.{1}\w+)?$' % (self.hostname))
- m = p.match(self.daemon_id)
- if m:
- return m.group(1)
-
+ pre, post = self.daemon_id.rsplit(self.hostname, 1)
+ if not pre.endswith('.'):
+ # '.' sep missing at front of hostname
+ raise err
+ elif post and not post.startswith('.'):
+ # '.' sep missing at end of hostname
+ raise err
+ return pre[:-1]
+
+ # daemon_id == "service_id.random"
if self.daemon_type == 'rgw':
v = self.daemon_id.split('.')
if len(v) in [3, 4]:
return '.'.join(v[0:2])
- raise OrchestratorError("DaemonDescription: Cannot calculate service_id: " \
- f"daemon_id='{self.daemon_id}' hostname='{self.hostname}'")
+ # daemon_id == "service_id"
+ return self.daemon_id
if self.daemon_type in ['mds', 'nfs', 'iscsi', 'rgw']:
return _match()