def __init__(self, *args: Any, **kwargs: Any):
super(CephadmOrchestrator, self).__init__(*args, **kwargs)
- self._cluster_fsid = self.get('mon_map')['fsid']
+ self._cluster_fsid: str = self.get('mon_map')['fsid']
self.last_monmap: Optional[datetime.datetime] = None
# for serve()
raise RuntimeError("unable to read cephadm at '%s': %s" % (
path, str(e)))
+ self.cephadm_binary_path = self._get_cephadm_binary_path()
+
self._worker_pool = multiprocessing.pool.ThreadPool(10)
self._reconfig_ssh()
assert service_type in ServiceSpec.KNOWN_SERVICE_TYPES
return self.cephadm_services[service_type]
+ def _get_cephadm_binary_path(self) -> str:
+ import hashlib
+ m = hashlib.sha256()
+ m.update(self._cephadm.encode())
+ return f'/var/lib/ceph/{self._cluster_fsid}/cephadm.{m.hexdigest()}'
+
def _kick_serve_loop(self) -> None:
self.log.debug('_kick_serve_loop')
self.event.set()
if daemon_spec.daemon_type == 'cephadm-exporter':
if not reconfig:
assert daemon_spec.host
- deploy_ok = self._deploy_cephadm_binary(daemon_spec.host)
- if not deploy_ok:
- msg = f"Unable to deploy the cephadm binary to {daemon_spec.host}"
- self.log.warning(msg)
- return msg
+ self._deploy_cephadm_binary(daemon_spec.host)
if daemon_spec.daemon_type == 'haproxy':
haspec = cast(HA_RGWSpec, self.mgr.spec_store[daemon_spec.service_name].spec)
return f"Host {host} failed to login to {url} as {username} with given password"
return None
- def _deploy_cephadm_binary(self, host: str) -> bool:
+ def _deploy_cephadm_binary(self, host: str) -> None:
# Use tee (from coreutils) to create a copy of cephadm on the target machine
self.log.info(f"Deploying cephadm binary to {host}")
with self._remote_connection(host) as tpl:
conn, _connr = tpl
_out, _err, code = remoto.process.check(
conn,
- ['tee', '-', '/var/lib/ceph/{}/cephadm'.format(self.mgr._cluster_fsid)],
+ ['tee', '-', self.mgr.cephadm_binary_path],
stdin=self.mgr._cephadm.encode('utf-8'))
- return code == 0
+ if code:
+ msg = f"Unable to deploy the cephadm binary to {host}: {_err}"
+ self.log.warning(msg)
+ raise OrchestratorError(msg)
@contextmanager
def _remote_connection(self,