Executing commands on a pod fails when only command kwarg is provided
See original GitHub issueWhen calling connect_get_namespaced_pod_exec
and providing only the required arguments + command, e.g. connect_get_namespaced_pod_exec("mypod", "namespace", command="ls")
, I get the following exception:
ApiException: (0)
# Reason: Handshake status 404
After debugging it, I found that the issue lies on how the query string is built for multiple values vs single ones:
The resulting url path + query string for the request above is: /api/v1/namespaces/default/pods/mypod/exec&command=ls
Note the lack of ?
when starting the query string.
But when giving another kwarg, e.g. connect_get_namespaced_pod_exec("mypod", "namespace", command="ls", stderr=True)
, the call works fine.
Note that this issue is specifically when using websockets. Relevant code is on websocket_call
Here’s a full example that reproduces my problem:
from kubernetes.client import configuration
from kubernetes import config
from kubernetes.client.apis import core_v1_api
configuration.assert_hostname = False
config.load_kube_config()
c = core_v1_api.CoreV1Api()
c.connect_get_namespaced_pod_exec("mypod", "namespace", command="ls")
# raises exception "Handshake status 404"
FTR, here’s where I first asked for/got help https://github.com/kubernetes-incubator/client-python/issues/36
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:10 (2 by maintainers)
Top GitHub Comments
Yeah, I’ll create one after my vacation.
It seems my issue was the lack of the “container” parameter since there are two in my pod. However, I needed to run the command through curl to get that message back from the system:
It doesn’t seem like the double ampersands cause any issue, but it’s easily fixed by changing:
to
in ws_client.py.