async def _logs(self, scheduler=True, workers=True): """ Return logs for the scheduler and workers Parameters ---------- scheduler : boolean Whether or not to collect logs for the scheduler workers : boolean or Iterable[str], optional A list of worker addresses to select. Defaults to all workers if `True` or no workers if `False` Returns ------- logs: Dict[str] A dictionary of logs, with one item for the scheduler and one for each worker """ logs = Logs() if scheduler: logs["Scheduler"] = await self.scheduler.logs() if workers: worker_logs = await asyncio.gather( *[w.logs() for w in self.workers.values()]) for key, log in zip(self.workers, worker_logs): logs[key] = log return logs
async def _get_logs(self): logs = Logs() pods = await self.core_api.list_namespaced_pod( namespace=self.namespace, label_selector=f"release={self.release_name},app=dask", ) for pod in pods.items: if "scheduler" in pod.metadata.name or "worker" in pod.metadata.name: try: if pod.status.phase != "Running": raise ValueError( f"Cannot get logs for pod with status {pod.status.phase}.", ) log = Log( await self.core_api.read_namespaced_pod_log( pod.metadata.name, pod.metadata.namespace ) ) except (ValueError, kubernetes.client.exceptions.ApiException): log = Log(f"Cannot find logs. Pod is {pod.status.phase}.") logs[pod.metadata.name] = log return logs
def test_logs(): d = Logs({"123": Log("Hello"), "456": Log("World!")}) text = d._repr_html_() for line in text.split("\n"): assert xml.etree.ElementTree.fromstring(line) is not None assert "Hello" in text assert "456" in text
def test_logs(): log = Log("Hello") assert isinstance(log, str) d = Logs({"123": log, "456": Log("World!")}) assert isinstance(d, dict) text = d._repr_html_() assert is_valid_xml("<div>" + text + "</div>") assert "Hello" in text assert "456" in text
async def _logs(self, scheduler=True, workers=True): logs = Logs() if scheduler: slogs = await self.scheduler_comm.logs() logs["Scheduler"] = Log("\n".join(line for level, line in slogs)) if workers: d = await self.scheduler_comm.worker_logs(workers=workers) for k, v in d.items(): logs[k] = Log("\n".join(line for level, line in v)) return logs
async def _get_logs(self): logs = Logs() pods = await self.core_api.list_namespaced_pod( namespace=self.namespace, label_selector=f"release={self.release_name},app=dask", ) for pod in pods.items: if "scheduler" in pod.metadata.name or "worker" in pod.metadata.name: logs[pod.metadata.name] = Log( await self.core_api.read_namespaced_pod_log( pod.metadata.name, pod.metadata.namespace)) return logs
async def _get_logs(self, cluster=True, scheduler=True, workers=True): logs = Logs() if cluster: logs["Cluster"] = Log("\n".join( line[1] for line in self._cluster_manager_logs)) if scheduler: L = await self.scheduler_comm.get_logs() logs["Scheduler"] = Log("\n".join(line for level, line in L)) if workers: if workers is True: workers = None d = await self.scheduler_comm.worker_logs(workers=workers) for k, v in d.items(): logs[k] = Log("\n".join(line for level, line in v)) return logs
def test_logs(): d = Logs({"123": Log("Hello"), "456": Log("World!")}) text = d._repr_html_() assert is_valid_xml("<div>" + text + "</div>") assert "Hello" in text assert "456" in text