Skip to content
This repository has been archived by the owner on Dec 1, 2018. It is now read-only.

WatchQuery KeyError #104

Open
jbeluch opened this issue Dec 19, 2016 · 2 comments
Open

WatchQuery KeyError #104

jbeluch opened this issue Dec 19, 2016 · 2 comments

Comments

@jbeluch
Copy link

jbeluch commented Dec 19, 2016

The json objects returned by WatchQuery don't seem to match up with the keys expected in the codebase.

Example code:

for thing in pykube.Pod.objects(api).watch():
    print(thing)

Relevant tb:

  File "/.../lib/python3.5/site-packages/pykube/query.py", line 156, in object_stream
    yield WatchEvent(type=we["type"], object=self.api_obj_class(self.api, we["object"]))
KeyError: 'type'
@jbeluch
Copy link
Author

jbeluch commented Dec 19, 2016

Perhaps the API changed at some point? It seems you need a watch=true URL parameter to signify a watch query to the server. So the above traceback is because the endpoint was returning a PodList instead of a stream of single objects. Something like

        if kwargs.get('stream'):
            params = kwargs.setdefault('params', {})
            params['watch'] = True

in HTTPClient.get_kwargs fixes it.

@hxquangnhat
Copy link

I think this has been fixed in release 0.14.0

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

No branches or pull requests

2 participants