-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Description
Hi!
I have an Azure k8s cluster where I run workflows with Kubeflow. One of the steps in my pipeline manually creates a pod (kubectl apply ...) and then starts reading logs generated by the container running in the created pod and printing them to the stdout so that they appear in the Kubeflow dashboard. The way I do it is as follows:
def get_logs(self):
response = self.v1.read_namespaced_pod_log(
name=self.launcher_pod,
namespace=self.train_job_namespace,
follow=True,
_preload_content=False,
pretty="true"
)
response_gen = response.stream(2 ** 6)
for line in response_gen:
try:
decoded_line = line.decode("utf-8")
except UnicodeDecodeError:
print(line)
continue
print(decoded_line, end="", flush=True)
print("INFO:: Logs reading thread has finished")
What I expect to happen - all logs that appear inside the container running in the pod to be successfully extracted and printed to the stdout of the corresponding Kubeflow step (which in turn runs in another pod inside the same cluster).
What happens - I get logs for some time but then they get stuck. If I SSH into the container running in the pod whose logs I want to read I can see the logs but I don't get them using the read_namespaced_pod_log() method running in a different pod.
Anything else we need to know?:
I've tried many different variations of the read_namespaced_pod_log's and stream's parameters but nothing seems to help - it works for a while (the time that passes before it stops printing logs seems to vary as well) and then it gets stuck.
Environment:
- Kubernetes version (
kubectl version
): 1.20.7 - OS (e.g., MacOS 10.13.6): Alpine Linux v3.14 (3.14.2)
- Python version (
python --version
) 3.9.6 - Python client version (
pip list | grep kubernetes
) 17.17.0
Thank you in advance!
Regards,
Evgenii