Skip to content

get error "Upgrade request required" for exec command using exec with connect_get_namespaced_pod_exec #526

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mpwusr opened this issue Apr 30, 2018 · 4 comments

Comments

@mpwusr
Copy link

mpwusr commented Apr 30, 2018

Python : get error "Upgrade request required" for exec command using exec with connect_get_namespaced_pod_exec

when I create the pod with python api I can use kubectl and run the following commands successfully at linux command line:

kubectl exec secret-pod --namespace=production cat data/busybox/username
and
kubectl exec secret-pod --namespace=production cat data/busybox/password

The following python code fails with "Upgrade request required"

def _get_user_token(self):
try:
user = self.core_api_instance.connect_get_namespaced_pod_exec(name="secret-pod",
namespace="production",
command=["cat /data/busybox/username"],
stderr=True, stdin=False,
stdout=True, tty=False)
pprint(user)
except ApiException as e:
print("Exception when calling CoreV1Api->get_namespaced_pod_exec: %s\n" % e)

    exec_cmd = ['cat /data/busybox/password']
    try:
        passwd = self.core_api_instance.connect_get_namespaced_pod_exec(name="secret-pod",
                                                                        namespace='production',
                                                                        command=["cat /data/busybox/password"],
                                                                        stderr=True, stdin=False,
                                                                        stdout=True, tty=False)
        pprint(passwd)
    except ApiException as e:
        print("Exception when calling CoreV1Api->get_namespaced_pod_exec: %s\n" % e)

    return {'user': user, 'password': passwd}
@mpwusr
Copy link
Author

mpwusr commented Apr 30, 2018

I upgraded kubernetes python package from 4.0.0 to 6.0.0 and websocket-client to 0.47.0 and it did not fix this

@mpwusr
Copy link
Author

mpwusr commented Jun 14, 2018

This is fixed by using a stream:
code change:

user_name_str = stream(self.core_api_instance.connect_get_namespaced_pod_exec, name,
namespace,command=exec_command1, stderr=True, stdin=False,
stdout=True, tty=False)

@adubkov
Copy link

adubkov commented Feb 27, 2019

Is there an example for stream with tty? to emulate kubectl exec -ti

@kasterma
Copy link

kasterma commented Mar 8, 2019

@adubkov Examples are at https://github.com/kubernetes-client/python/blob/master/examples/exec.py where interestingly enough the one that runs interactively works for me, the one that does not hangs for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants