Skip to content

Conversation

chaosbox
Copy link
Contributor

@chaosbox chaosbox commented Jul 9, 2024

For #6511

This PR adds support for configuration of different types of compression, including none, in the default HTTP filter chain.

Related #310, there had been mentions about disabling compression, the ticket we had raised shows the reason where disabling compression can bring cost benefits.

@chaosbox chaosbox requested a review from a team as a code owner July 9, 2024 09:04
@chaosbox chaosbox requested review from skriss and sunjayBhatia and removed request for a team July 9, 2024 09:04
@sunjayBhatia sunjayBhatia requested review from a team, rajatvig and davinci26 and removed request for a team July 9, 2024 09:18
Copy link

github-actions bot commented Jul 9, 2024

Hi @chaosbox! Welcome to our community and thank you for opening your first Pull Request. Someone will review it soon. Thank you for committing to making Contour better. You can also join us on our mailing list and in our channel in the Kubernetes Slack Workspace

dependabot bot and others added 2 commits July 9, 2024 10:42
…jectcontour#6543)

Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 3.3.0 to 3.4.0.
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](docker/setup-buildx-action@d70bba7...4fd8129)

---
updated-dependencies:
- dependency-name: docker/setup-buildx-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: chaosbox <ram29@bskyb.com>
…ponse compression

Signed-off-by: chaosbox <ram29@bskyb.com>
Copy link

The Contour project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 14d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, the PR is closed

You can:

  • Ensure your PR is passing all CI checks. PRs that are fully green are more likely to be reviewed. If you are having trouble with CI checks, reach out to the #contour channel in the Kubernetes Slack workspace.
  • Mark this PR as fresh by commenting or pushing a commit
  • Close this PR
  • Offer to help out with triage

Please send feedback to the #contour channel in the Kubernetes Slack

@github-actions github-actions bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jul 25, 2024
@chaosbox
Copy link
Contributor Author

Ping

@github-actions github-actions bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jul 29, 2024
@tsaarni tsaarni added the release-note/small A small change that needs one line of explanation in the release notes. label Aug 2, 2024
# Conflicts:
#	.github/workflows/build_main.yaml
#	.github/workflows/build_tag.yaml
#	.github/workflows/prbuild.yaml
Copy link
Member

@tsaarni tsaarni left a comment

Choose a reason for hiding this comment

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

I've included suggestions inline for some linter nags (link).

Please add the new disableCompression option in "Configuration File" chapter in site/content/docs/main/configuration.md.

Please add also a changelog file.

@geomacy
Copy link
Contributor

geomacy commented Aug 19, 2024

Thanks very much for the feedback @tsaarni 🙇 we'll have a look at this and try to get back with updates as soon as possible.

@geomacy
Copy link
Contributor

geomacy commented Aug 21, 2024

Many thanks for taking the time to provide the lint fixes. We'll update the docs and add the changelog as soon as possible.

Copy link

codecov bot commented Aug 21, 2024

Codecov Report

Attention: Patch coverage is 92.30769% with 6 lines in your changes missing coverage. Please review.

Project coverage is 80.72%. Comparing base (38346c5) to head (30c8fb6).
Report is 20 commits behind head on main.

Files with missing lines Patch % Lines
pkg/config/parameters.go 57.14% 2 Missing and 1 partial ⚠️
internal/envoy/v3/listener.go 96.07% 1 Missing and 1 partial ⚠️
cmd/contour/serve.go 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #6546      +/-   ##
==========================================
+ Coverage   80.70%   80.72%   +0.02%     
==========================================
  Files         131      131              
  Lines       19816    19868      +52     
==========================================
+ Hits        15993    16039      +46     
- Misses       3533     3537       +4     
- Partials      290      292       +2     
Files with missing lines Coverage Δ
cmd/contour/servecontext.go 84.91% <100.00%> (+0.53%) ⬆️
internal/xdscache/v3/listener.go 91.71% <100.00%> (+0.07%) ⬆️
cmd/contour/serve.go 21.89% <0.00%> (-0.03%) ⬇️
internal/envoy/v3/listener.go 98.27% <96.07%> (-0.24%) ⬇️
pkg/config/parameters.go 87.04% <57.14%> (-0.65%) ⬇️
🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@geomacy geomacy force-pushed the main branch 3 times, most recently from 619ac16 to 16f72d7 Compare August 22, 2024 16:38
Geoff Macartney and others added 5 commits August 22, 2024 17:46
Co-authored-by: Tero Saarni <tero.saarni@est.tech>
Signed-off-by: Geoff Macartney <geoff.macartney@sky.uk>
Co-authored-by: Tero Saarni <tero.saarni@est.tech>
Signed-off-by: Geoff Macartney <geoff.macartney@sky.uk>
Co-authored-by: Tero Saarni <tero.saarni@est.tech>
Signed-off-by: Geoff Macartney <geoff.macartney@sky.uk>
Co-authored-by: Tero Saarni <tero.saarni@est.tech>
Signed-off-by: Geoff Macartney <geoff.macartney@sky.uk>
Co-authored-by: Tero Saarni <tero.saarni@est.tech>
Signed-off-by: Geoff Macartney <geoff.macartney@sky.uk>
Signed-off-by: Geoff Macartney <geoff.macartney@sky.uk>
@geomacy
Copy link
Contributor

geomacy commented Nov 28, 2024

hi @tsaarni what do you think about the above changes and question?

a better name is SetDefaultFilterCompression

Signed-off-by: Geoff Macartney <geoff.macartney@sky.uk>
@geomacy
Copy link
Contributor

geomacy commented Dec 6, 2024

hi @tsaarni I have thought about the above further and I do feel that the clarification of the method's usage is the best approach - I have added this in 2f5e157.

Please have another look at the latest batch of commits, thanks.

@chaosbox chaosbox changed the title disableCompression: Expose configuration to toggle Envoy GZIP compression on the responses Adds support for configuration of different types of compression, including none, in the default HTTP filter chain. Dec 10, 2024
@chaosbox chaosbox changed the title Adds support for configuration of different types of compression, including none, in the default HTTP filter chain. Adds support for configuration of different types of compression, including none Dec 10, 2024
@geomacy
Copy link
Contributor

geomacy commented Dec 11, 2024

@tsaarni any thoughts please?

@geomacy
Copy link
Contributor

geomacy commented Dec 18, 2024

hi @tsaarni, @davinci26, @sunjayBhatia we would really appreciate it if you could get back to us on this pull request, which has been sitting for some weeks. I believe from the above conversations that this is either ready for final approval and merge, or very nearly so. The changes on this PR have been going on for a long time and it would be really good to get it finished off at last. Thanks!

@geomacy
Copy link
Contributor

geomacy commented Jan 2, 2025

hi @tsaarni, @davinci26, @sunjayBhatia please let us know how we can get this ticket reviewed and accepted. We would really like to get this out of the way if at all possible.

@sunjayBhatia sunjayBhatia modified the milestone: 1.31.0 Jan 13, 2025
Copy link

The Contour project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 14d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, the PR is closed

You can:

  • Ensure your PR is passing all CI checks. PRs that are fully green are more likely to be reviewed. If you are having trouble with CI checks, reach out to the #contour channel in the Kubernetes Slack workspace.
  • Mark this PR as fresh by commenting or pushing a commit
  • Close this PR
  • Offer to help out with triage

Please send feedback to the #contour channel in the Kubernetes Slack

@github-actions github-actions bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 29, 2025
Copy link
Member

@tsaarni tsaarni left a comment

Choose a reason for hiding this comment

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

Apologies for being unavailable to review once again :( Aside from the minor comments, the PR looks good to go.

hi @tsaarni I have thought about the above further and I do feel that the clarification of the method's usage is the best approach - I have added this in 2f5e157.

I've now also tried to implement various alternatives on top of this PR, including adding Compressor with an explicit call rather than as default. However, there are so many unit tests to adjust accordingly, that it becomes unnecessarily high impact. Instead, I have added suggestion to add panic() to enforce the correct order.


// EnvoyCompression defines configuration related to compression in the default HTTP Listener filter chain.
type EnvoyCompression struct {
// Algorithm selects the compression type applied in the compression HTTP filter of the default Listener filters.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Algorithm selects the compression type applied in the compression HTTP filter of the default Listener filters.
// Algorithm selects the response compression type applied in the compression HTTP filter of the default Listener filters.

type EnvoyCompression struct {
// Algorithm selects the compression type applied in the compression HTTP filter of the default Listener filters.
// Values: `gzip` (default), `brotli`, `zstd`, `disabled`.
// Setting this to `disabled` will make Envoy skip "Accept-Encoding: gzip,deflate" request header and always return uncompressed response
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Setting this to `disabled` will make Envoy skip "Accept-Encoding: gzip,deflate" request header and always return uncompressed response
// Setting this to `disabled` will make Envoy skip "Accept-Encoding: gzip,deflate" request header and always return uncompressed response.

// SetDefaultFilterCompression configures the builder to set the compression method applied by DefaultFilters() to the
// given value `compressor`. When chaining builder method calls, this method should be called before DefaultFilters().
func (b *httpConnectionManagerBuilder) SetDefaultFilterCompression(compressor *contour_v1alpha1.EnvoyCompression) *httpConnectionManagerBuilder {
b.compression = compressor
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if SetDefaultFilterCompression() communicates that this function must be called in a specific order? Personally I don't find it immediately clear. We could simply add enforce with panic and use the previous name Compression() which sounded better to me.

Suggested change
b.compression = compressor
if len(b.filters) > 0 {
panic("Compression must be set before adding filters")
}
b.compression = compressor

The approach has precedence, as simiar pattern is already used here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @tsaarni will make those changes as soon as possible.

Copy link
Member

Choose a reason for hiding this comment

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

I believe make generate needs to be run once again, and the generated files should be committed. Additionally, the following patch aligns with the latest changes related to HTTPConnectionManagerBuilder and fixes the compile errors.

diff --git a/internal/featuretests/v3/compression_test.go b/internal/featuretests/v3/compression_test.go
index b374ed92..94e28756 100644
--- a/internal/featuretests/v3/compression_test.go
+++ b/internal/featuretests/v3/compression_test.go
@@ -28,6 +28,10 @@ import (
 )

 func TestCompression(t *testing.T) {
+       envoyGen := envoy_v3.NewEnvoyGen(envoy_v3.EnvoyGenOpt{
+               XDSClusterName: envoy_v3.DefaultXDSClusterName,
+       })
+
        tests := map[string]struct {
                algorithm contour_v1alpha1.CompressionAlgorithm
                want      contour_v1alpha1.CompressionAlgorithm
@@ -75,7 +79,7 @@ func TestCompression(t *testing.T) {
                        rh.OnAdd(s1)
                        rh.OnAdd(hp1)
                        httpListener := defaultHTTPListener()
-                       httpListener.FilterChains = envoy_v3.FilterChains(envoy_v3.HTTPConnectionManagerBuilder().
+                       httpListener.FilterChains = envoy_v3.FilterChains(envoyGen.HTTPConnectionManagerBuilder().
                                Compression(&contour_v1alpha1.EnvoyCompression{
                                        Algorithm: tc.want,
                                }).
diff --git a/internal/xdscache/v3/listener_test.go b/internal/xdscache/v3/listener_test.go
index 6e6e994f..299f9963 100644
--- a/internal/xdscache/v3/listener_test.go
+++ b/internal/xdscache/v3/listener_test.go
@@ -3093,7 +3093,7 @@ func TestListenerVisit(t *testing.T) {
                                Name:    ENVOY_HTTP_LISTENER,
                                Address: envoy_v3.SocketAddress("0.0.0.0", 8080),
                                FilterChains: envoy_v3.FilterChains(
-                                       envoy_v3.HTTPConnectionManagerBuilder().
+                                       envoyGen.HTTPConnectionManagerBuilder().
                                                Compression(&contour_v1alpha1.EnvoyCompression{
                                                        Algorithm: contour_v1alpha1.DisabledCompression,
                                                }).
@@ -3139,7 +3139,7 @@ func TestListenerVisit(t *testing.T) {
                                Name:    ENVOY_HTTP_LISTENER,
                                Address: envoy_v3.SocketAddress("0.0.0.0", 8080),
                                FilterChains: envoy_v3.FilterChains(
-                                       envoy_v3.HTTPConnectionManagerBuilder().
+                                       envoyGen.HTTPConnectionManagerBuilder().
                                                Compression(&contour_v1alpha1.EnvoyCompression{
                                                        Algorithm: contour_v1alpha1.GzipCompression,
                                                }).
@@ -3185,7 +3185,7 @@ func TestListenerVisit(t *testing.T) {
                                Name:    ENVOY_HTTP_LISTENER,
                                Address: envoy_v3.SocketAddress("0.0.0.0", 8080),
                                FilterChains: envoy_v3.FilterChains(
-                                       envoy_v3.HTTPConnectionManagerBuilder().
+                                       envoyGen.HTTPConnectionManagerBuilder().
                                                Compression(&contour_v1alpha1.EnvoyCompression{
                                                        Algorithm: contour_v1alpha1.BrotliCompression,
                                                }).
@@ -3231,7 +3231,7 @@ func TestListenerVisit(t *testing.T) {
                                Name:    ENVOY_HTTP_LISTENER,
                                Address: envoy_v3.SocketAddress("0.0.0.0", 8080),
                                FilterChains: envoy_v3.FilterChains(
-                                       envoy_v3.HTTPConnectionManagerBuilder().
+                                       envoyGen.HTTPConnectionManagerBuilder().
                                                Compression(&contour_v1alpha1.EnvoyCompression{
                                                        Algorithm: contour_v1alpha1.ZstdCompression,
                                                }).
@@ -3277,7 +3277,7 @@ func TestListenerVisit(t *testing.T) {
                                Name:    ENVOY_HTTP_LISTENER,
                                Address: envoy_v3.SocketAddress("0.0.0.0", 8080),
                                FilterChains: envoy_v3.FilterChains(
-                                       envoy_v3.HTTPConnectionManagerBuilder().
+                                       envoyGen.HTTPConnectionManagerBuilder().
                                                Compression(&contour_v1alpha1.EnvoyCompression{
                                                        Algorithm: contour_v1alpha1.GzipCompression,
                                                }).

Copy link
Contributor

Choose a reason for hiding this comment

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

hi @tsaarni thanks, yes I have work in progress on this here: chaosbox#5 that fixes the above, but I see there are also test failures that I haven't had the chance to look at yet. I am sorry this is taking so long, I am completely flat out at the moment and haven't got to look at this. I hope to get a chance to get on to it soon, thanks for your patience!!

Copy link
Member

Choose a reason for hiding this comment

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

No problem! Lets get back to this when you have time.

Copy link
Contributor

Choose a reason for hiding this comment

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

hi @tsaarni that's all merged now, it would be great if you could approve to run the tests.

@tsaarni tsaarni removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 29, 2025
Geoff Macartney added 10 commits February 12, 2025 09:13
Signed-off-by: Geoff Macartney <geoff.macartney@sky.uk>
Signed-off-by: Geoff Macartney <geoff.macartney@sky.uk>
Signed-off-by: Geoff Macartney <geoff.macartney@sky.uk>
Signed-off-by: Geoff Macartney <geoff.macartney@sky.uk>
Signed-off-by: Geoff Macartney <geoff.macartney@sky.uk>
Signed-off-by: Geoff Macartney <geoff.macartney@sky.uk>
Signed-off-by: Geoff Macartney <geoff.macartney@sky.uk>
Signed-off-by: Geoff Macartney <geoff.macartney@sky.uk>
Signed-off-by: Geoff Macartney <geoff.macartney@sky.uk>
Signed-off-by: Geoff Macartney <geoff.macartney@sky.uk>
@geomacy
Copy link
Contributor

geomacy commented Mar 7, 2025

hello @tsaarni I had to do another lint fix on the PR, can you enable tests again?

Copy link
Member

@tsaarni tsaarni left a comment

Choose a reason for hiding this comment

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

Thank You @geomacy and @chaosbox for this contribution and for your patience! Apologies once more for the long delay.

@tsaarni tsaarni merged commit 8c44fd2 into projectcontour:main Mar 10, 2025
26 checks passed
@geomacy
Copy link
Contributor

geomacy commented Mar 10, 2025

Many thanks @tsaarni it's really great to see this merged. Thanks for your patience in turn!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note/small A small change that needs one line of explanation in the release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants