Repository navigation
How do you get exit code connect_get_namespaced_pod_exec ? #812
Description
Activity
@oz123 The error code arrives in the channel number 3 (error-channel) but it is not exposed by the stream() method.
As a workaround you can use:
from kubernetes.stream.ws_client import ERROR_CHANNEL .... client = stream(api.connect_get_namespaced_pod_exec, "myapp-78898448f4-pgnfl", "default", command=["false"], # <<< "false" returns with exit code = 1 stderr=True, stdin=False, stdout=True, tty=False, _preload_content=False) # <<< we need a client object client.run_forever(timeout=60) err = client.read_channel(ERROR_CHANNEL) pprint(yaml.load(err))and you should get
{'details': {'causes': [{'message': '1', 'reason': 'ExitCode'}]}, 'message': 'command terminated with non-zero exit code: Error executing in ' 'Docker Container: 1', 'metadata': {}, 'reason': 'NonZeroExitCode', 'status': 'Failure'}I'm going to add a method to get it in more convenient way.
- Reacted by Tomas Tomecek
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- addedlifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.Denotes an issue or PR has remained open with no activity and has become stale.
on Sep 4, 2019 fixed by kubernetes-client/python-base#160
/close
@roycaihw: Closing this issue.
Details
In response to this:
fixed by kubernetes-client/python-base#160
/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.
When I run this as
resp = stream(v1.connect_get_namespaced_pod_exec, podName, namespace, command=exec_command, stderr=True, stdin=False, stdout=True, tty=False, _preload_content=preloadContent)
resp.run_forever(timeout=5)
print(resp.readline_channel(1))Response:
NoneHowever, print(resp.read_channel(1)) gives me proper output.
Any pointers why?
Currently I have to simply do this:
However, I can't get the error code, or the stderror.
Looking at the source code I don't see an easy way.