Skip to content
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

Python kubernetes client breaks when parsing the response from custom controller #139

Open
ccamacho opened this issue Jun 26, 2019 · 2 comments

Comments

Projects
None yet
1 participant
@ccamacho
Copy link

commented Jun 26, 2019

Issue: Python kubernetes client breaks when parsing the response from custom controller

When running a watch primitive as:
resource_version = ''
while True:
stream = watch.Watch().stream(crds.list_cluster_custom_object, DOMAIN, "v1", "guitars", resource_version=resource_version)

The python client breaks with:

Traceback (most recent call last):
File "controller-pods.py", line 39, in
for event in stream:
File "/usr/lib/python2.7/site-packages/kubernetes/watch/watch.py", line 154, in stream
for line in iter_resp_lines(resp):
File "/usr/lib/python2.7/site-packages/kubernetes/watch/watch.py", line 60, in iter_resp_lines
resp = resp.read_chunked(decode_content=False)
AttributeError: 'HTTPResponse' object has no attribute 'read_chunked'

Packages versions:
rpm -qf /usr/lib/python2.7/site-packages/openshift/dynamic/client.py /usr/lib/python2.7/site-packages/kubernetes/watch/watch.py

python2-openshift-0.8.8-1.el7.noarch
python2-kubernetes-8.0.1-1.el7.noarch

Workaround, it seems that in this case the response does not allow to be chunked, using instead **read() in[1]:

https://github.com/kubernetes-client/python-base/blob/master/watch/watch.py#L48

Before:
for seg in resp.read_chunked(decode_content=False):
After:
for seg in resp.read():

Seemed to work fine.

ccamacho added a commit to ccamacho/python-base that referenced this issue Jun 26, 2019

Check if its possible to parse a chunked response
This patch is a simple check for either read the chunks
of the response of use the standard read method.

Currently if it is not possible to use the 'read_chunked'
method the client fails.

This commit fixes kubernetes-client#139

@ccamacho ccamacho referenced a pull request that will close this issue Jun 26, 2019

Open

Check if its possible to parse a chunked response #140

ccamacho added a commit to ccamacho/python-base that referenced this issue Jun 26, 2019

Check if its possible to parse a chunked response
This patch is a simple check for either read the chunks
of the response of use the standard read method.
Currently if it is not possible to use the read_chunked
method the client fails.
This commit fixes kubernetes-client#139
@ccamacho

This comment has been minimized.

Copy link
Author

commented Jun 26, 2019

Fix proposed in #140

@ccamacho

This comment has been minimized.

Copy link
Author

commented Jun 29, 2019

Making fail also Ansible Kubevirt kubevirt/ansible-kubevirt-modules#222

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.