return (cert_str, key_str)
def get_root_cert(self) -> str:
- return crypto.dump_certificate(crypto.FILETYPE_PEM, self.root_cert).decode('utf-8')
+ try:
+ return crypto.dump_certificate(crypto.FILETYPE_PEM, self.root_cert).decode('utf-8')
+ except AttributeError:
+ return ''
def get_root_key(self) -> str:
- return crypto.dump_privatekey(crypto.FILETYPE_PEM, self.root_key).decode('utf-8')
+ try:
+ return crypto.dump_certificate(crypto.FILETYPE_PEM, self.root_key).decode('utf-8')
+ except AttributeError:
+ return ''
self.config_checker = CephadmConfigChecks(self)
- self.cherrypy_thread = None
+ self.cherrypy_thread = CherryPyThread(self)
+ self.cherrypy_thread.start()
self.agent_helpers = CephadmAgentHelpers(self)
-
if self.use_agent:
- try:
- if not self.cherrypy_thread:
- self.cherrypy_thread = CherryPyThread(self)
- self.cherrypy_thread.start()
- if 'agent' not in self.spec_store:
- self.agent_helpers._apply_agent()
- except Exception as e:
- self.log.error(f'Failed to initialize agent spec and cherrypy server: {e}')
+ self.agent_helpers._apply_agent()
def shutdown(self) -> None:
self.log.debug('shutdown')
self._worker_pool.close()
self._worker_pool.join()
- if self.cherrypy_thread:
- self.cherrypy_thread.shutdown()
- self.cherrypy_thread = None
+ self.cherrypy_thread.shutdown()
self.run = False
self.event.set()
DaemonDescriptionStatus, daemon_type_to_service
from cephadm.services.cephadmservice import CephadmDaemonDeploySpec
from cephadm.schedule import HostAssignment
-from cephadm.agent import CherryPyThread
from cephadm.autotune import MemoryAutotuner
from cephadm.utils import forall_hosts, cephadmNoImage, is_repo_digest, \
CephadmNoImage, CEPH_TYPES, ContainerInspectInfo
self._purge_deleted_services()
if self.mgr.use_agent:
- if not self.mgr.cherrypy_thread:
- self.mgr.cherrypy_thread = CherryPyThread(self.mgr)
- self.mgr.cherrypy_thread.start()
+ # on the off chance there are still agents hanging around from
+ # when we turned the config option off, we need to redeploy them
+ # we can tell they're in that state if we don't have a keyring for
+ # them in the host cache
+ for agent in self.mgr.cache.get_daemons_by_service('agent'):
+ if agent.hostname not in self.mgr.cache.agent_keys:
+ self.mgr._schedule_daemon_action(agent.name(), 'redeploy')
if 'agent' not in self.mgr.spec_store:
self.mgr.agent_helpers._apply_agent()
+ for host in self.mgr.cache.get_hosts():
+ self.mgr.cache.metadata_up_to_date[host] = False
else:
- if self.mgr.cherrypy_thread:
- self.mgr.cherrypy_thread.shutdown()
- self.mgr.cherrypy_thread = None
if 'agent' in self.mgr.spec_store:
self.mgr.spec_store.rm('agent')
+ self.mgr.cache.agent_counter = {}
+ self.mgr.cache.agent_timestamp = {}
+ self.mgr.cache.agent_keys = {}
+ self.mgr.cache.agent_ports = {}
if self.mgr.upgrade.continue_upgrade():
continue
assert dd.hostname is not None
assert dd.daemon_type is not None
assert dd.daemon_id is not None
- if not spec and dd.daemon_type not in ['mon', 'mgr', 'osd', 'agent']:
+ if not spec and dd.daemon_type not in ['mon', 'mgr', 'osd']:
# (mon and mgr specs should always exist; osds aren't matched
# to a service spec)
self.log.info('Removing orphan daemon %s...' % dd.name())
'host': daemon_spec.host,
'device_enhanced_scan': str(self.mgr.get_module_option('device_enhanced_scan'))}
- assert self.mgr.cherrypy_thread
- assert self.mgr.cherrypy_thread.ssl_certs.get_root_cert()
+ try:
+ assert self.mgr.cherrypy_thread
+ assert self.mgr.cherrypy_thread.ssl_certs.get_root_cert()
+ except Exception:
+ raise OrchestratorError(
+ 'Cannot deploy agent daemons until cephadm endpoint has finished generating certs')
listener_cert, listener_key = self.mgr.cherrypy_thread.ssl_certs.generate_cert(
daemon_spec.host)
config = {