-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
internal server error when call watch on list_pod_for_all_namespace #701
Comments
I've been testing a patch that seems to have worked around this same issue for me, going to throw up a PR once I'm sure I'm not breaking anything; --- a/kubernetes/watch/watch.py 2018-12-13 12:55:30.282078582 +0100
+++ b/kubernetes/watch/watch.py 2018-12-13 12:57:34.727886214 +0100
@@ -79,17 +79,23 @@
def unmarshal_event(self, data, return_type):
js = json.loads(data)
js['raw_object'] = js['object']
+ version = None
if return_type:
obj = SimpleNamespace(data=json.dumps(js['raw_object']))
js['object'] = self._api_client.deserialize(obj, return_type)
if hasattr(js['object'], 'metadata'):
- self.resource_version = js['object'].metadata.resource_version
- # For custom objects that we don't have model defined, json
- # deserialization results in dictionary
- elif (isinstance(js['object'], dict) and 'metadata' in js['object']
- and 'resourceVersion' in js['object']['metadata']):
- self.resource_version = js['object']['metadata'][
- 'resourceVersion']
+ version = js['object'].metadata.resource_version
+ # For custom objects that we don't have model defined, json
+ # deserialization results in dictionary
+ if (version is None
+ and isinstance(js['object'], dict)
+ and 'metadata' in js['object']
+ and 'resourceVersion' in js['object']['metadata']):
+ version = js['object']['metadata']['resourceVersion']
+
+ if version is not None:
+ self.resource_version = version
+
return js
def stream(self, func, *args, **kwargs): Edit: Broke - not everything but - a few things. Written up a new patch instead; --- a/kubernetes/watch/watch.py 2018-12-14 08:15:10.574488606 +0100
+++ b/kubernetes/watch/watch.py 2018-12-14 08:30:41.285017302 +0100
@@ -14,6 +14,7 @@
import json
import pydoc
+import re
from kubernetes import client
@@ -123,12 +124,27 @@
kwargs['watch'] = True
kwargs['_preload_content'] = False
+ reloading = None
timeouts = ('timeout_seconds' in kwargs)
while True:
+ reloading = False
resp = func(*args, **kwargs)
try:
for line in iter_resp_lines(resp):
- yield self.unmarshal_event(line, return_type)
+ ev = self.unmarshal_event(line, return_type)
+ raw = ev['raw_object']
+
+ if 'Status' in raw.get('kind', '') and\
+ 'Failure' in raw.get('status', '') and\
+ 'Gone' in raw.get('reason', ''):
+ new_ver = re.search("\((\d+)\)",
+ raw.get('message',''))
+ if new_ver and new_ver.group(1):
+ self.resource_version = int(new_ver.group(1)) + 1
+ reloading = True
+ break
+
+ yield ev
if self._stop:
break
finally:
@@ -136,5 +156,5 @@
resp.close()
resp.release_conn()
- if timeouts or self._stop:
+ if (timeouts or self._stop) and not reloading:
break |
I'm running into the same issue. Something not right here, as we see the response |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Rotten issues close after 30d of inactivity. Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
@fejta-bot: Closing this issue. In response to this:
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. |
my code is like this
and the code throws
ApiException(500)
I'm not sure if this is a bug in python client or kubernetes itself.
The text was updated successfully, but these errors were encountered: