What happened (please include outputs or screenshots):
Watch.stream() raises ApiTypeError when used with CoreV1Api.read_namespaced_pod_log:
kubernetes.client.exceptions.ApiTypeError: Got an unexpected keyword argument 'watch' to method read_namespaced_pod_log
What you expected to happen:
Till a recent update this has been working. I feel the reason is that the watch module defines PYDOC_FOLLOW_PARAM = ":param bool follow:" but that format is no longer used as it is now split into 2 lines
How to reproduce it (as minimally and precisely as possible):
kind create cluster
pip install kubernetes>=36.0.0
python reproducer.py
kind delete cluster
reproducer.py:
"""Reproducer: Watch.stream() fails with read_namespaced_pod_log on kubernetes >= 36.0.0"""
import time
from kubernetes import client, config, watch
NAMESPACE = "default"
POD_NAME = "watch-bug-reproducer"
config.load_kube_config()
v1 = client.CoreV1Api()
pod = client.V1Pod(
metadata=client.V1ObjectMeta(name=POD_NAME),
spec=client.V1PodSpec(
containers=[
client.V1Container(
name="busybox",
image="busybox",
command=["sh", "-c", "while true; do echo hello from pod; sleep 1; done"],
)
]
),
)
print(f"Creating pod {POD_NAME}...")
v1.create_namespaced_pod(namespace=NAMESPACE, body=pod)
print("Waiting for pod to be running...")
while True:
pod_status = v1.read_namespaced_pod_status(name=POD_NAME, namespace=NAMESPACE)
if pod_status.status.phase == "Running":
break
time.sleep(1)
print("Pod is running. Attempting Watch.stream() with read_namespaced_pod_log...")
w = watch.Watch()
for line in w.stream(v1.read_namespaced_pod_log, name=POD_NAME, namespace=NAMESPACE):
print(f"Got log line: {line}")
break
Anything else we need to know?:
I hope the fix is as simple as updating PYDOC_FOLLOW_PARAM but I am not sure if there is anything else to be considered.
Environment:
- Kubernetes version (
kubectl version):
- OS Fedora 43:
- Python version 3.14
- Python client version
master and 36.0.2
What happened (please include outputs or screenshots):
Watch.stream()raisesApiTypeErrorwhen used withCoreV1Api.read_namespaced_pod_log:What you expected to happen:
Till a recent update this has been working. I feel the reason is that the watch module defines
PYDOC_FOLLOW_PARAM = ":param bool follow:"but that format is no longer used as it is now split into 2 linesHow to reproduce it (as minimally and precisely as possible):
kind create cluster pip install kubernetes>=36.0.0 python reproducer.py kind delete clusterreproducer.py:Anything else we need to know?:
I hope the fix is as simple as updating
PYDOC_FOLLOW_PARAMbut I am not sure if there is anything else to be considered.Environment:
kubectl version):masterand 36.0.2