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

stream+ws_client: Optional capture-all #178

Merged
merged 2 commits into from
Jan 6, 2020

Conversation

rawler
Copy link
Contributor

@rawler rawler commented Nov 27, 2019

This PR is a proposal to fix kubernetes-client/python#1013.

The fix is two-fold:

  1. Improve the way WSClient._all is appended to, to avoid exponential slow-down.
  2. Allow optional disabling of the "capture-all" behavior, to remove memory-usage altogether

@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.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please sign in with your organization's credentials at https://identity.linuxfoundation.org/projects/cncf to be authorized.
  • If you have done the above and are still having issues with the CLA being reported as unsigned, please log a ticket with the Linux Foundation Helpdesk: https://support.linuxfoundation.org/
  • Should you encounter any issues with the Linux Foundation Helpdesk, send a message to the backup e-mail support address at: [email protected]

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 Nov 27, 2019
@k8s-ci-robot
Copy link
Contributor

Welcome @rawler!

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 size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Nov 27, 2019
@rawler
Copy link
Contributor Author

rawler commented Nov 27, 2019

Side-note; As a user of the stream-API, the usage is not immediately clear, and it's also a bit inflexible. (Stdout is not necessarily characters?) I think this has room for some breaking API-improvements;

  • Adding clarity to what kwargs and I can and cannot specify - stream() kwargs should be explicit and documented
  • Supporting binary stdin/out. I had to work around this by use of base64. The data received seems to be bytes, the utf8-assumption is done in
    data = data.decode("utf-8", "replace")
  • Buffering _all could potentially be a composed opt-in, rather than a default-integrated behavior.

I made a short attempt to add explicit **kwargs (which could be non-breaking), but it snowballed into scope-creep, and I realized I don't know the code well enough to feel comfortable making such changes.

@rawler rawler force-pushed the optional-capture-all branch 3 times, most recently from daaf9b5 to 2a2e74b Compare November 27, 2019 10:50
@rawler
Copy link
Contributor Author

rawler commented Nov 27, 2019

I signed it

@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 Nov 27, 2019
@rawler rawler force-pushed the optional-capture-all branch 2 times, most recently from 2b61e72 to 4a9317d Compare November 27, 2019 12:31
bytes() += bytes() copies both buffers into a new one, causing exponential
cost and gradual slow-down. Replacing with StringIO improves that
@rawler rawler force-pushed the optional-capture-all branch from 4a9317d to 368d0d7 Compare November 27, 2019 12:45
@rawler
Copy link
Contributor Author

rawler commented Nov 27, 2019

/assign @mbohlool

@codecov-io
Copy link

Codecov Report

Merging #178 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #178   +/-   ##
=======================================
  Coverage   93.41%   93.41%           
=======================================
  Files          13       13           
  Lines        1398     1398           
=======================================
  Hits         1306     1306           
  Misses         92       92

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a2d1024...368d0d7. Read the comment docs.

@roycaihw
Copy link
Member

roycaihw commented Dec 3, 2019

/assign

@roycaihw
Copy link
Member

roycaihw commented Jan 6, 2020

/lgtm
/approve

Thanks for the improvement!

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rawler, roycaihw

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 Jan 6, 2020
@k8s-ci-robot k8s-ci-robot merged commit 278105e into kubernetes-client:master Jan 6, 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.

WSClient._all grows uncontrolled and inefficiently
5 participants