Open tusharrobin opened 2 weeks ago
/assign @yliaog
timeout should be a float, not a tuple as the error suggests
Exception when calling CoreV1Api->connect_get_namespaced_pod_exec: (0) Reason: '<' not supported between instances of 'float' and 'tuple'
Hi @yliaog, Thanks for looking into this.
The documentation for the API mentions
:param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.
If there is another way to set connect_timeout, let me know. Thanks again !
I see. please checkout https://github.com/kubernetes-client/python/blob/master/examples/watch/timeout-settings.md
In case if the pod is on a node which is network partitioned and if you execute command in a pod running on that node, it will take 30 seconds to timeout even if you set "_request_timeout" to be a lesser value.
If you use curl with "connect_timeout" to a smaller value, it does timeout after that duration so we need to set connect_timeout for the "connect_get_namespaced_pod_exec" api so that it can timeout during network partition.
The only option I see in kubernetes client is to set the _request_timeout to a tuple value which allows to set "connect_timeout" which is not working. Can you please check if there is an issue ?
What happened (please include outputs or screenshots):
Executing command in pod fails if _request_timeout is passed as tuple. The exact error is
Exception when calling CoreV1Api->connect_get_namespaced_pod_exec: (0) Reason: '<' not supported between instances of 'float' and 'tuple'
What you expected to happen: Expected to run the command successfully.
How to reproduce it (as minimally and precisely as possible):
`from kubernetes import client, config from kubernetes.stream import stream
def run_command_in_pod(namespace, pod_name, container_name, command, timeout): config.load_kube_config() c = client.Configuration() c.debug = True api_instance = client.CoreV1Api()
if name == 'main': namespace = 'test' pod_name = 'test' container_name = 'test' command = 'date' timeout = (5, 10)
Anything else we need to know?:
Environment:
kubectl version
): 1.30python --version
) 3.9pip list | grep kubernetes
) kubernetes-31.0.0