Skip to content
This repository was archived by the owner on Mar 13, 2022. It is now read-only.

fix stream data decoding - #112

Closed
dbazhal wants to merge 45 commits into
kubernetes-client:masterfrom
dbazhal:master
Closed

dbazhal wants to merge 45 commits into
kubernetes-client:masterfrom
dbazhal:master

Conversation

@dbazhal

@dbazhal dbazhal commented Jan 21, 2019

Copy link
Copy Markdown

Related to #88 and #104
I suppose decoding complete data is better than decoding data chunks.
Would be nice to get review from @mbohlool and @saberuster

@k8s-ci-robot

Copy link
Copy Markdown
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


Details

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. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Jan 21, 2019
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jan 21, 2019
@dbazhal

dbazhal commented Jan 23, 2019

Copy link
Copy Markdown
Author

Ok, i think I now signed the cla, hope the bot will reconcile that.

juliantaylor and others added 2 commits January 23, 2019 19:38
The watch code reset the version to the last found in the
response.
When you first list existing objects and then start watching from that
resource version the existing versions are older than the version you
wanted and the watch starts from the wrong version after the first
restart.
This leads to for example already deleted objects ending in the stream
again.

Fix this by setting the minimum resource version to reset from to the
input resource version. As long as k8s returns all objects in order in
the watch this should work.
We cannot use the integer value of the resource version to order it as
one should be treat the value as opaque.

Closes kubernetes-client/python#700
fix watching with a specified resource version
@dbazhal

dbazhal commented Jan 31, 2019

Copy link
Copy Markdown
Author

@roycaihw or @micw523 or @yliaog guys, mb any of you could take a look at my pr, or #104 please? don't want to patch this in all my controllers, and with current amount of objects in crds they fail with unicode decode errors like every hour :D

Comment thread stream/ws_client.py Outdated
index = data.find("\n")
newline_symbol = "\n"
if six.PY3:
newline_Symbol = b"\n"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although it does the same thing, I wonder why you applied different logic compared to Line 44. Also, be careful about your variable name: do you mean newline_symbol instead of a capitalized S?

@dbazhal dbazhal Jan 31, 2019 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uh-oh, my bad, fixed that. i'll test this code tomorrorow.
and it'd be great if you could judge the solution to decoding errors itself, it bothers me more than anything else :) maybe you will find solution from #104 better than this one

@micw523

micw523 commented Jan 31, 2019

Copy link
Copy Markdown
Contributor

Also, it doesn't seem like your CLA has been updated yet. You sure you signed it?

tx to micw comments
@dbazhal

dbazhal commented Jan 31, 2019

Copy link
Copy Markdown
Author

Also, it doesn't seem like your CLA has been updated yet. You sure you signed it?

thought i signed it. now signed for sure, and email/uid match. i hope bot will recognize that

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jan 31, 2019
```
Traceback (most recent call last):
  File "controller_unitproject/run.py", line 33, in <module>
    run()
  File "controller_unitproject/run.py", line 29, in run
    unitproject.run()
  File "/home/bajal/.local/share/virtualenvs/controller_unitproject-1u3cbEWP/lib/python3.7/site-packages/module_k8s_controller_sdk/controller.py", line 215, in run
    self.resync_and_watch()
  File "/home/bajal/.local/share/virtualenvs/controller_unitproject-1u3cbEWP/lib/python3.7/site-packages/module_k8s_controller_sdk/controller.py", line 209, in resync_and_watch
    from_version=last_known_resource_version
  File "/home/bajal/.local/share/virtualenvs/controller_unitproject-1u3cbEWP/lib/python3.7/site-packages/module_k8s_controller_sdk/watcher.py", line 92, in watch
    self.__watch(seconds_to_out)
  File "/home/bajal/.local/share/virtualenvs/controller_unitproject-1u3cbEWP/lib/python3.7/site-packages/module_k8s_controller_sdk/watcher.py", line 51, in __watch
    for event in stream:
  File "/home/bajal/.local/share/virtualenvs/controller_unitproject-1u3cbEWP/lib/python3.7/site-packages/kubernetes/watch/watch.py", line 130, in stream
    for line in iter_resp_lines(resp):
  File "/home/bajal/.local/share/virtualenvs/controller_unitproject-1u3cbEWP/lib/python3.7/site-packages/kubernetes/watch/watch.py", line 47, in iter_resp_lines
    seg = seg.decode('utf8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd0 in position 2047: unexpected end of data
```
@dbazhal

dbazhal commented Feb 1, 2019

Copy link
Copy Markdown
Author

Fixed one more bug about decoding - now inside watch.py.
All changes tested and work fine 👍

@roycaihw

roycaihw commented Feb 4, 2019

Copy link
Copy Markdown
Member

commented in #104 (comment). I think we should decode utf8 only if opcode is Text

@dbazhal

dbazhal commented Mar 25, 2019

Copy link
Copy Markdown
Author

Hey guys, what else can I do to help with this one? @roycaihw ?

@leavest leavest mentioned this pull request Apr 20, 2019
@dbazhal

dbazhal commented May 16, 2019

Copy link
Copy Markdown
Author

I dunno if it is acceptable to up threads, but it would be nice to get any answer ^_^

@roycaihw

Copy link
Copy Markdown
Member

@dbazhal sorry for the late reply. I will review this pull this week

@dbazhal

dbazhal commented Jun 6, 2019

Copy link
Copy Markdown
Author

just another firendly reminder :)

@roycaihw

Copy link
Copy Markdown
Member

@dbazhal my apologies.. was busy with k/k 1.15 freeze. Please take a look at #104 (comment). I think recv_data_frame handles fragment concatenation already, so we don't have to concatenate the messages on top of that

dbazhal and others added 10 commits June 20, 2019 20:53
Related to #88 and #104
I suppose decoding complete data is better than decoding data chunks.
tx to micw comments
```
Traceback (most recent call last):
  File "controller_unitproject/run.py", line 33, in <module>
    run()
  File "controller_unitproject/run.py", line 29, in run
    unitproject.run()
  File "/home/bajal/.local/share/virtualenvs/controller_unitproject-1u3cbEWP/lib/python3.7/site-packages/module_k8s_controller_sdk/controller.py", line 215, in run
    self.resync_and_watch()
  File "/home/bajal/.local/share/virtualenvs/controller_unitproject-1u3cbEWP/lib/python3.7/site-packages/module_k8s_controller_sdk/controller.py", line 209, in resync_and_watch
    from_version=last_known_resource_version
  File "/home/bajal/.local/share/virtualenvs/controller_unitproject-1u3cbEWP/lib/python3.7/site-packages/module_k8s_controller_sdk/watcher.py", line 92, in watch
    self.__watch(seconds_to_out)
  File "/home/bajal/.local/share/virtualenvs/controller_unitproject-1u3cbEWP/lib/python3.7/site-packages/module_k8s_controller_sdk/watcher.py", line 51, in __watch
    for event in stream:
  File "/home/bajal/.local/share/virtualenvs/controller_unitproject-1u3cbEWP/lib/python3.7/site-packages/kubernetes/watch/watch.py", line 130, in stream
    for line in iter_resp_lines(resp):
  File "/home/bajal/.local/share/virtualenvs/controller_unitproject-1u3cbEWP/lib/python3.7/site-packages/kubernetes/watch/watch.py", line 47, in iter_resp_lines
    seg = seg.decode('utf8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd0 in position 2047: unexpected end of data
```
Following comment #112 (comment)
Tested on running controller.
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: dbazhal
To complete the pull request process, please assign roycaihw
You can assign the PR to them by writing /assign @roycaihw in a comment when ready.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 20, 2019
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


Details

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. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. and removed cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jun 20, 2019
@dbazhal dbazhal closed this Jun 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.