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

Refs. #151 -- detect binary payloads and send the correct opcode #152

Merged
merged 1 commit into from
Feb 14, 2020
Merged

Refs. #151 -- detect binary payloads and send the correct opcode #152

merged 1 commit into from
Feb 14, 2020

Conversation

sergei-maertens
Copy link
Contributor

@sergei-maertens sergei-maertens commented Aug 14, 2019

On Python 2, strings are bytestrings either way. On Python 3, the
result of chr(channel) is str, while the data itself is
bytes. The channel prefix needs to be turned into a binary type,
and the websocket frame needs the correct opcode (binary vs. text).

See #151 for the bug report and related issues.

This is basically the same fix as #52 but with a different approach and passes the opcode argument to indicate a binary frame.

@k8s-ci-robot
Copy link
Contributor

Welcome @sergei-maertens!

It looks like this is your first PR to kubernetes-client/python-base 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-client/python-base has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Aug 14, 2019
@k8s-ci-robot
Copy link
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.


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. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Aug 14, 2019
@sergei-maertens
Copy link
Contributor Author

/assign @mbohlool

@sergei-maertens
Copy link
Contributor Author

sergei-maertens commented Aug 14, 2019

I'm not sure what the best way to test this is, without a real, functioning underlying websocket. The only test in ws_client_test.py didn't really give any good pointers either.

edit: saw that CI handles this with downstream 👍

@sergei-maertens sergei-maertens changed the title Fixes #151 -- detect binary payloads and send the correct opcode Refs. #151 -- detect binary payloads and send the correct opcode Aug 14, 2019
On Python 2, strings are bytestrings either way. On Python 3, the
result of `chr(channel)` is `str`, while the data itself is
`bytes`. The channel prefix needs to be turned into a binary type,
and the websocket frame needs the correct opcode (binary vs. text).

See #151 for the bug report and related issues.
@sergei-maertens
Copy link
Contributor Author

What is needed to progress this PR? Anything I can do?

@roycaihw
Copy link
Member

/uncc @mbohlool
/unassign @mbohlool
/assign

@k8s-ci-robot k8s-ci-robot assigned roycaihw and unassigned mbohlool Sep 13, 2019
@k8s-ci-robot k8s-ci-robot removed the request for review from mbohlool September 13, 2019 22:20
channel_prefix = six.binary_type(channel_prefix, "ascii")

payload = channel_prefix + data
self.sock.send(payload, opcode=opcode)
Copy link
Member

Choose a reason for hiding this comment

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

Could you add a test case here that writes binary data?

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Dec 16, 2019
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jan 15, 2020
@Ark-kun
Copy link
Contributor

Ark-kun commented Feb 11, 2020

It would be nice to have a working support for getting binary data from pods.

@Ark-kun
Copy link
Contributor

Ark-kun commented Feb 11, 2020

/remove-lifecycle rotten

@k8s-ci-robot k8s-ci-robot removed the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label Feb 11, 2020
@roycaihw
Copy link
Member

It would be nice to have a working support for getting binary data from pods.

@Ark-kun this change focus on writing binary data. Please open a separate issue if there is a problem with reading binary data.

@roycaihw
Copy link
Member

A testcase that demonstrates the fix would be nice. @sergei-maertens Are you still interested in this issue?

@sergei-maertens
Copy link
Contributor Author

sergei-maertens commented Feb 12, 2020 via email

@roycaihw
Copy link
Member

I just realized that the e2e test I asked for in #152 (comment) belongs to a different repo. I agree in this case keeping python and python-base separate causes a bad contributor experience. @sergei-maertens I'm sorry for the confusion.

I'm still not comfortable getting this bug fix in without a test, but the test and the bug being in two repos means we cannot merge them in the same time. Given the behavior change is well scoped, and the original bytes behavior is broken. I will merge this change and open an issue to track adding a test.

@roycaihw
Copy link
Member

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 14, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: roycaihw, sergei-maertens

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

The pull request process is described here

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 the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 14, 2020
@k8s-ci-robot k8s-ci-robot merged commit a25f49e into kubernetes-client:master Feb 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants