if host not in [h.hostname for h in self.mgr.cache.get_non_draining_hosts()]:
return False
# if we haven't deployed an agent on the host yet, don't say an agent is down
- if not [a for a in self.mgr.cache.get_daemons_by_type('agent') if a.hostname == host]:
+ if not self.mgr.cache.get_daemons_by_type('agent', host=host):
return False
# if we don't have a timestamp, it's likely because of a mgr fail over.
# just set the timestamp to now. However, if host was offline before, we
try:
# try to schedule redeploy of agent in case it is individually down
- agent = [a for a in self.mgr.cache.get_daemons_by_type(
- 'agent') if a.hostname == host][0]
+ agent = self.mgr.cache.get_daemons_by_type('agent', host=host)[0]
with self.mgr.agent_helpers.agent_lock(host):
daemon_spec = CephadmDaemonDeploySpec.from_daemon_description(agent)
self.mgr._daemon_action(daemon_spec, action='redeploy')
return True
else:
try:
- agent = [a for a in self.mgr.cache.get_daemons_by_type(
- 'agent') if a.hostname == host][0]
+ agent = self.mgr.cache.get_daemons_by_type('agent', host=host)[0]
assert agent.daemon_id is not None
assert agent.hostname is not None
except Exception as e:
r.append(dd)
return r
- def get_error_daemons(self):
- # type: () -> List[orchestrator.DaemonDescription]
+ def get_error_daemons(self) -> List[orchestrator.DaemonDescription]:
r = []
for host, dm in self.daemons.items():
for name, dd in dm.items():
result.append(d)
return result
- def get_daemons_by_type(self, service_type):
- # type: (str) -> List[orchestrator.DaemonDescription]
+ def get_daemons_by_type(self, service_type: str, host: str = '') -> List[orchestrator.DaemonDescription]:
assert service_type not in ['keepalived', 'haproxy']
result = [] # type: List[orchestrator.DaemonDescription]
- for host, dm in self.daemons.items():
+ for h, dm in self.daemons.items():
+ if host and h != host:
+ continue
for name, d in dm.items():
if d.daemon_type in service_to_daemon_types(service_type):
result.append(d)
seconds=self.mgr.daemon_cache_timeout)
if host not in self.last_daemon_update or self.last_daemon_update[host] < cutoff:
return True
+ if not self.mgr.cache.host_metadata_up_to_date(host):
+ return True
return False
def host_needs_facts_refresh(self, host):
seconds=self.mgr.facts_cache_timeout)
if host not in self.last_facts_update or self.last_facts_update[host] < cutoff:
return True
+ if not self.mgr.cache.host_metadata_up_to_date(host):
+ return True
return False
def host_needs_autotune_memory(self, host):
seconds=self.mgr.device_cache_timeout)
if host not in self.last_device_update or self.last_device_update[host] < cutoff:
return True
+ if not self.mgr.cache.host_metadata_up_to_date(host):
+ return True
return False
def host_needs_network_refresh(self, host):
seconds=self.mgr.device_cache_timeout)
if host not in self.last_network_update or self.last_network_update[host] < cutoff:
return True
+ if not self.mgr.cache.host_metadata_up_to_date(host):
+ return True
return False
def host_needs_osdspec_preview_refresh(self, host: str) -> bool:
or host not in [h.hostname for h in self.mgr.cache.get_non_draining_hosts()]
or host in agents_down
):
- if (
- self.mgr.cache.host_needs_daemon_refresh(host)
- or not self.mgr.cache.host_metadata_up_to_date(host)
- ):
+ if self.mgr.cache.host_needs_daemon_refresh(host):
self.log.debug('refreshing %s daemons' % host)
r = self._refresh_host_daemons(host)
if r:
failures.append(r)
- if (
- self.mgr.cache.host_needs_facts_refresh(host)
- or not self.mgr.cache.host_metadata_up_to_date(host)
- ):
+ if self.mgr.cache.host_needs_facts_refresh(host):
self.log.debug(('Refreshing %s facts' % host))
r = self._refresh_facts(host)
if r:
failures.append(r)
- if (
- self.mgr.cache.host_needs_network_refresh(host)
- or not self.mgr.cache.host_metadata_up_to_date(host)
- ):
+ if self.mgr.cache.host_needs_network_refresh(host):
self.log.debug(('Refreshing %s networks' % host))
r = self._refresh_host_networks(host)
if r:
failures.append(r)
- if (
- self.mgr.cache.host_needs_device_refresh(host)
- or not self.mgr.cache.host_metadata_up_to_date(host)
- ):
+ if self.mgr.cache.host_needs_device_refresh(host):
self.log.debug('refreshing %s devices' % host)
r = self._refresh_host_devices(host)
if r:
failures.append(r)
self.mgr.cache.metadata_up_to_date[host] = True
- elif not [a for a in self.mgr.cache.get_daemons_by_type('agent') if a.hostname == host]:
- if (
- self.mgr.cache.host_needs_daemon_refresh(host)
- or not self.mgr.cache.host_metadata_up_to_date(host)
- ):
+ elif not self.mgr.cache.get_daemons_by_type('agent', host=host):
+ if self.mgr.cache.host_needs_daemon_refresh(host):
self.log.debug('refreshing %s daemons' % host)
r = self._refresh_host_daemons(host)
if r: