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 logs(self): try: log = await self.core_api.read_namespaced_pod_log( self._pod.metadata.name, self.namespace) except ApiException as e: if "waiting to start" in str(e): log = "" else: raise e return Log(log)
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
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
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