When 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
Using 3.0.0 from pip and python3.6, I get the same issue. However, the workaround of supplying another parameter does not work for me. Is there something else I could try to get this working? My resulting URL is a bit more complex, but even "ls" fails for me:
/api/v1/namespaces/demo/pods/mongo-0/exec?stderr=True&command=mongo&&command=admin&&command=--eval&&command=db.createUser%28%5C%7B+user%3A+%27myuser%27%2C+pwd%3A+%27mypass%27%2C+roles%3A+%5B%7B%27role%27%3A+%27userAdminAnyDatabase%27%2C+%27db%27%3A+%27admin%27%7D%5D+%5C%7D%29&
Have you tried with 2.0.0? your url seems broken in a different way than mine was, you've got duplicated &, and my problem was that I got no ? at the beginning of the query string, so it makes sense that the work around doesn't fix it for you:(
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:
HTTP/1.1 400 Bad Request
Content-Type: application/json
Date: Wed, 30 Aug 2017 02:20:52 GMT
Content-Length: 231
{
"kind": "Status",
"apiVersion": "v1",
"metadata": {},
"status": "Failure",
"message": "a container name must be specified for pod mongo-0, choose one of: [mongo mongo-sidecar]",
"reason": "BadRequest",
"code": 400
}
It doesn't seem like the double ampersands cause any issue, but it's easily fixed by changing:
url += "&command=%s&" % quote_plus(command)
to
url += "&command=%s" % quote_plus(command)
in ws_client.py.
@eyeofthefrog nice catch. can you send a PR to fix ws_client.py?
Yeah, I'll create one after my vacation.
Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale
Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
If this issue is safe to close now please do so with /close.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten
Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close
@fejta-bot: Closing this issue.
In response to this:
Rotten issues close after 30d of inactivity.
Reopen the issue with/reopen.
Mark the issue as fresh with/remove-lifecycle rotten.Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
Most helpful comment
Yeah, I'll create one after my vacation.