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

Feature: Add config setting to disable gzip compression #1627 #1628

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

markdingram
Copy link
Contributor

Copy link

codecov bot commented Nov 5, 2024

Codecov Report

Attention: Patch coverage is 87.87879% with 4 lines in your changes missing coverage. Please review.

Project coverage is 75.5%. Comparing base (179936a) to head (22dfd0a).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
kube-client/src/client/builder.rs 87.5% 4 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main   #1628     +/-   ##
=======================================
+ Coverage   75.3%   75.5%   +0.3%     
=======================================
  Files         82      82             
  Lines       7344    7376     +32     
=======================================
+ Hits        5528    5567     +39     
+ Misses      1816    1809      -7     
Files with missing lines Coverage Δ
kube-client/src/config/file_config.rs 75.2% <ø> (+1.0%) ⬆️
kube-client/src/config/mod.rs 53.4% <100.0%> (+8.4%) ⬆️
kube-client/src/client/builder.rs 66.4% <87.5%> (+7.9%) ⬆️

... and 1 file with indirect coverage changes

@clux clux added the changelog-add changelog added category for prs label Nov 5, 2024
@clux clux added this to the 0.97.0 milestone Nov 5, 2024
@clux clux linked an issue Nov 5, 2024 that may be closed by this pull request
.layer(tower_http::decompression::DecompressionLayer::new())
.layer(
tower_http::decompression::DecompressionLayer::new()
.no_br()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

intentionally disable anything but GZIP compression -

reading kubernetes/kubernetes#112296 show there isn't like to be any other option in Kube for a while, but these flags could easily be refitted when/if Kube gains alternatives.

Copy link
Member

Choose a reason for hiding this comment

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

agreed. think this is sensible also.

@@ -158,7 +158,13 @@ where
#[cfg(feature = "gzip")]
let stack = ServiceBuilder::new()
.layer(stack)
.layer(tower_http::decompression::DecompressionLayer::new())
.layer(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

trying to wrap the whole layer in an "option_layer" block ran head first into a load of compile issues - fortunately the Compression Layer supports enabling/disabling through configuration hence that path was chosen

@markdingram
Copy link
Contributor Author

Remaining work on this PR is to add a test to check the Accept-Encoding header when the disabled flag is set

@markdingram markdingram force-pushed the disable-compression branch 3 times, most recently from 62c7009 to 71598b8 Compare November 6, 2024 23:03
@markdingram markdingram marked this pull request as ready for review November 7, 2024 12:17
Copy link
Member

@clux clux left a comment

Choose a reason for hiding this comment

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

Looks great! Thank you very much. Sensible porting of upstream behavior and sensible defaulting.

we've not historically been great at testing this area of the code base and this is a very nice way of doing it

Comment on lines +284 to +297
// confirm gzip echoed back with default config
let config = Config { ..Config::new(uri) };
let client = make_generic_builder(HttpConnector::new(), config.clone())?.build();
let response = client.request_text(http::Request::default()).await?;
assert_eq!(&response, "gzip");

// now disable and check empty string echoed back
let config = Config {
disable_compression: true,
..config
};
let client = make_generic_builder(HttpConnector::new(), config)?.build();
let response = client.request_text(http::Request::default()).await?;
assert_eq!(&response, "");
Copy link
Member

Choose a reason for hiding this comment

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

wow great test. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog-add changelog added category for prs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add "disable-compression" to selectively disable Client Compression
2 participants