Description
What happened (please include outputs or screenshots):
Empty newlines skipped when watching pod logs
What you expected to happen:
Empty newlines not skipped when watching pod logs
How to reproduce it (as minimally and precisely as possible):
Run the following in a kubernetes contexxt:
from kubernetes import client, config, watch
pod_name = "demo-bug"
config.load_kube_config()
api = client.CoreV1Api()
namespace = config.list_kube_config_contexts()[1]["context"]["namespace"]
pod_manifest = {
"apiVersion": "v1",
"kind": "Pod",
"metadata": {
"name": pod_name,
},
"spec": {
"containers": [{"image": "hello-world", "name": pod_name}],
},
}
api.create_namespaced_pod(body=pod_manifest, namespace=namespace)
input("Submit when running")
w = watch.Watch()
for e in w.stream(
api.read_namespaced_pod_log,
name=pod_name,
namespace=namespace,
follow=True,
):
print(e)
The output that returns is:
Submit when running
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
The output that I expect is:
$ podman run --rm hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
Anything else we need to know?:
Environment:
- Kubernetes version (
kubectl version
): - OS (e.g., MacOS 10.13.6):
- Python version (
python --version
) - Python client version (
pip list | grep kubernetes
)
Client Version: v1.29.4
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.29.4
Red Hat Enterprise Linux release 8.10
Python 3.11.3
kubernetes 32.0.0+snapshot