alex-kharlamov / KubeResearch

MIT License
1 stars 0 forks source link

[run] stop if log stopped #35

Open github-actions[bot] opened 9 months ago

github-actions[bot] commented 9 months ago

https://github.com/alex-kharlamov/KubeResearch/blob/38af014b8a2111e8146b33ac124cadbfbef36861/kubr/commands/run.py#L103


                    run_state = "Container"

            if event_object.message == f"Started container {job.name}":
                progress.update(container_pb, advance=node_update_step)
                started_containers += 1
                if started_containers == job.nodes:
                    status.update("Waiting for logs...")
                    break

            if "pod group is not ready" in event_object.message and len(pod_events):
                status.update(f"{run_state}... {event_object.message}\n \t Pod issue: {pod_events[-1].message}")
            else:
                status.update(f"{run_state}... {event_object.message}")

        log_found = 0
        while True:
            sleep(2)
            try:
                log_stream = self.backend.get_logs(job_name=job.name, namespace=job.namespace, tail=None, follow=True)
                for log in log_stream:
                    # TODO [run] stop if log stopped
                    if not log_found:
                        status.update("Job started!")
                        live_panel.stop()
                    print(log)
                    log_found += 1

                break
            except Exception:
                status.update("Waiting for logs...")

    def __call__(
        self,