-
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
feat: add switch control when watching events whether deserialization… #2369
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -172,14 +172,19 @@ def stream(self, func, *args, **kwargs): | |
# We want to ensure we are returning within that timeout. | ||
disable_retries = ('timeout_seconds' in kwargs) | ||
retry_after_410 = False | ||
deserialize = kwargs.pop('deserialize', False) | ||
while True: | ||
resp = func(*args, **kwargs) | ||
try: | ||
for line in iter_resp_lines(resp): | ||
# unmarshal when we are receiving events from watch, | ||
# return raw string when we are streaming log | ||
if watch_arg == "watch": | ||
event = self.unmarshal_event(line, return_type) | ||
if deserialize: | ||
event = self.unmarshal_event(line, return_type) | ||
else: | ||
# Only do basic JSON parsing, no deserialize | ||
event = json.loads(line) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here We need to make sure the retry logic continue to work even when we don't deserialize the object There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also noticed that in this way, the resource version is not tracked like here does. I think we can refactor the unmarshal_event method to keep track of the resource version even when we skip deserialization. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please update the tests to ensure the retry and resource version behaviors when |
||
if isinstance(event, dict) \ | ||
and event['type'] == 'ERROR': | ||
obj = event['raw_object'] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We actually have the return_type flag which could serve the purpose, but it looks pretty unintuitive-- IIUC
_raw_return_type
can be persisted by settingreturn_type
toFalse
, which would result in deserialization being skippedThat being said, the flag name seems unintuitive and I think
deserialize = False
makes more sense.cc @yliaog
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 on deserialize = False