Skip to content
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

Disable Requesting Compression by default on restclient #48477

Closed

Conversation

ilackarms
Copy link
Contributor

@ilackarms ilackarms commented Jul 4, 2017

Background:
The HTTP2 Transport used by internal HTTP Clients in Kubernetes by default adds the header Accept-Encoding: gzip to all HTTP requests (and then attempts to decompress responses that contain the header Content-Encoding: gzip) in a way that is transparent to the caller. This behavior can be disabled using the DisableCompression field of the http.Transport. Since #46966 the kube apiserver now supports gzipping HTTP responses as per client request. Enabling this feature causes increased CPU usage as all internal clients are consuming it by default.

What this PR does / why we need it:
This PR exposes DisableCompression and makes it configurable via the new field *restclient.Config.DisableCompression (which is set to true by default). This should have the benefit of enabling API Compression support (e.g. for external clients) without causing unwanted CPU overhead. Internal clients that wish to request compression should be made to do so explicitly.

Release note:

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 4, 2017
@k8s-ci-robot
Copy link
Contributor

Hi @ilackarms. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

I understand the commands that are listed here.

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 needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jul 4, 2017
@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ilackarms
We suggest the following additional approvers: deads2k, yujuhong

Assign the PR to them by writing /assign @deads2k @yujuhong in a comment when ready.

Associated issue: 46966

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

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot k8s-github-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. release-note-label-needed labels Jul 4, 2017
@ilackarms ilackarms force-pushed the configure-client-compression branch from b4f3905 to 9d72a26 Compare July 4, 2017 17:30
@k8s-github-robot k8s-github-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 4, 2017
@ilackarms
Copy link
Contributor Author

@deads2k cc

@cblecker
Copy link
Member

cblecker commented Jul 4, 2017

/ok-to-test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jul 4, 2017
@ilackarms ilackarms force-pushed the configure-client-compression branch 4 times, most recently from 00f4396 to 6fb79fd Compare July 4, 2017 22:03
@@ -131,6 +131,7 @@ func (config *DirectClientConfig) ClientConfig() (*restclient.Config, error) {

clientConfig := &restclient.Config{}
clientConfig.Host = configClusterInfo.Server
clientConfig.DisableCompression = true
Copy link
Member

Choose a reason for hiding this comment

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

this seems odd... this is setting a non-zero value for a field in the restclient.Config that does not come from the provided or overridden config inputs... that is unique in this function, and I don't think we want it here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the restclient.Config passes through quite a few functions before it is used to configure the transport. Is there a function you think is more appropriate for setting this in the restclient.Config?

return http.DefaultTransport, nil
tr := http.DefaultTransport
if defaultTransport, ok := tr.(*http.Transport); ok {
defaultTransport.DisableCompression = config.DisableCompression
Copy link
Member

Choose a reason for hiding this comment

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

this is changing the DisableCompression setting in the shared http.DefaultTransport, which affects all users of that transport (and possibly http.DefaultClient)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe instead of using http.DefaulTransport here it makes more sense to create a "Default Client" (copy the fields of http.DefaultTransport into a new *http.Transport)? then apply config.DisableCompression

@ilackarms ilackarms force-pushed the configure-client-compression branch from 6fb79fd to f7d2d07 Compare July 5, 2017 18:07
@k8s-github-robot k8s-github-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jul 5, 2017
@ilackarms ilackarms force-pushed the configure-client-compression branch from f7d2d07 to 0b7a676 Compare July 5, 2017 18:45
@k8s-github-robot k8s-github-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 5, 2017
@ilackarms ilackarms force-pushed the configure-client-compression branch from 0b7a676 to ebd0e51 Compare July 5, 2017 20:15
@ilackarms
Copy link
Contributor Author

@liggitt @deads2k good to merge?

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 5, 2017
@ilackarms ilackarms force-pushed the configure-client-compression branch from ebd0e51 to 69fcc76 Compare August 5, 2017 14:05
@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 5, 2017
@ilackarms ilackarms force-pushed the configure-client-compression branch from 69fcc76 to 5f41b1e Compare August 8, 2017 17:32
@ilackarms
Copy link
Contributor Author

/retest

@bazulay
Copy link

bazulay commented Aug 14, 2017

@liggitt @deads2k PTAL

@liggitt
Copy link
Member

liggitt commented Aug 25, 2017

were there any client-level issues we found with compression or did it "just work" from the client side with the default go transports? I'd like to avoid making clients care about this if possible. The main cpu hit would be on the apiserver, so the existing flag there seems sufficient to me.

@ilackarms
Copy link
Contributor Author

enabling API compression did not cause any problems for internal clients. an increased number of test flakes occurred as a result of #45666 due to increased CPU load on the master, which led to reverting #45666 in favor of #46966 which added API Compression with default-to-off feature gating. the goal of this change is to open the possibility of enabling API compression by default on the server side without causing the test flakes seen previously.

@liggitt
Copy link
Member

liggitt commented Aug 28, 2017

the goal of this change is to open the possibility of enabling API compression by default on the server side without causing the test flakes seen previously.

Enabling a feature without exercising it consistently is likely to put us in the position of having a feature enabled without actually understanding the impact. I don't think pushing the burden of opting in onto every client is a great idea. There was work done on the test that started flaking that brought it back from the timeout thresholds it was dancing around. Instead of this change, I'd rather discuss enabling by default, with use by internal clients, and run the CI job enough times prior to merge to understand the runtime impact, and coordinate with the scale tests (kubemark) after merge to test it there as well.

@ilackarms
Copy link
Contributor Author

I'd rather discuss enabling by default, with use by internal clients, and run the CI job enough times prior to merge to understand the runtime impact, and coordinate with the scale tests (kubemark) after merge to test it there as well.

@liggitt i agree. in that case, closing this PR in favor #51508 where we can test the effect of enabling Compression by default. thanks for the update

@ilackarms ilackarms closed this Aug 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants