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: http buffer filter configuration (#6249) #6315

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions apis/projectcontour/v1alpha1/contourconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,11 @@ type EnvoyListener struct {
// AccessLog defines where Envoy logs are outputted for this listener.
// +optional
AccessLog string `json:"accessLog,omitempty"`

// Sets the max_request_bytes value for the http.buffer filter.
// If the value is 0, it skips adding a Buffer filter into the filter chain.
// +optional
BufferMaxRequestBytes uint32 `json:"bufferMaxRequestBytes,omitempty"`
}

// EnvoyLogging defines how Envoy's logs can be configured.
Expand Down
3 changes: 3 additions & 0 deletions changelogs/unreleased/6315-ruzmuh-minor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## http buffer filter configuration

Introduce two optional config parameter `http-buffer-max-request-bytes`, with default values set to `0`. If the value is non-zero, an HTTP buffer filter will be added to the HTTP filter chain immediately after the `DefaultFilters()` with the `max_request_bytes` parameter. This configuration allows setting the buffer filter for the entire HTTP listeners only (both http and https).
2 changes: 2 additions & 0 deletions cmd/contour/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,8 @@
HTTP2MaxConcurrentStreams: contourConfiguration.Envoy.Listener.HTTP2MaxConcurrentStreams,
PerConnectionBufferLimitBytes: contourConfiguration.Envoy.Listener.PerConnectionBufferLimitBytes,
SocketOptions: contourConfiguration.Envoy.Listener.SocketOptions,
HTTPBufferMaxRequestBytes: contourConfiguration.Envoy.HTTPListener.BufferMaxRequestBytes,
HTTPSBufferMaxRequestBytes: contourConfiguration.Envoy.HTTPSListener.BufferMaxRequestBytes,

Check warning on line 472 in cmd/contour/serve.go

View check run for this annotation

Codecov / codecov/patch

cmd/contour/serve.go#L471-L472

Added lines #L471 - L472 were not covered by tests
}

if listenerConfig.TracingConfig, err = s.setupTracingService(contourConfiguration.Tracing); err != nil {
Expand Down
14 changes: 8 additions & 6 deletions cmd/contour/servecontext.go
Original file line number Diff line number Diff line change
Expand Up @@ -543,14 +543,16 @@ func (ctx *serveContext) convertToContourConfigurationSpec() contour_v1alpha1.Co
Namespace: ctx.Config.EnvoyServiceNamespace,
},
HTTPListener: &contour_v1alpha1.EnvoyListener{
Address: ctx.httpAddr,
Port: ctx.httpPort,
AccessLog: ctx.httpAccessLog,
Address: ctx.httpAddr,
Port: ctx.httpPort,
AccessLog: ctx.httpAccessLog,
BufferMaxRequestBytes: ctx.Config.HTTPBufferMaxRequestBytes,
},
HTTPSListener: &contour_v1alpha1.EnvoyListener{
Address: ctx.httpsAddr,
Port: ctx.httpsPort,
AccessLog: ctx.httpsAccessLog,
Address: ctx.httpsAddr,
Port: ctx.httpsPort,
AccessLog: ctx.httpsAccessLog,
BufferMaxRequestBytes: ctx.Config.HTTPBufferMaxRequestBytes,
},
Metrics: &envoyMetrics,
Health: &contour_v1alpha1.HealthConfig{
Expand Down
11 changes: 11 additions & 0 deletions cmd/contour/servecontext_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,17 @@ func TestConvertServeContext(t *testing.T) {
return cfg
},
},
"envoy buffer filter": {
getServeContext: func(ctx *serveContext) *serveContext {
ctx.Config.HTTPBufferMaxRequestBytes = 10
return ctx
},
getContourConfiguration: func(cfg contour_v1alpha1.ContourConfigurationSpec) contour_v1alpha1.ContourConfigurationSpec {
cfg.Envoy.HTTPListener.BufferMaxRequestBytes = 10
cfg.Envoy.HTTPSListener.BufferMaxRequestBytes = 10
return cfg
},
},
}

for name, tc := range cases {
Expand Down
24 changes: 24 additions & 0 deletions examples/contour/01-crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,12 @@ spec:
description: Defines an Envoy Listener Address.
minLength: 1
type: string
bufferMaxRequestBytes:
description: |-
Sets the max_request_bytes value for the http.buffer filter.
If the value is 0, it skips adding a Buffer filter into the filter chain.
format: int32
type: integer
port:
description: Defines an Envoy listener Port.
type: integer
Expand All @@ -267,6 +273,12 @@ spec:
description: Defines an Envoy Listener Address.
minLength: 1
type: string
bufferMaxRequestBytes:
description: |-
Sets the max_request_bytes value for the http.buffer filter.
If the value is 0, it skips adding a Buffer filter into the filter chain.
format: int32
type: integer
port:
description: Defines an Envoy listener Port.
type: integer
Expand Down Expand Up @@ -3935,6 +3947,12 @@ spec:
description: Defines an Envoy Listener Address.
minLength: 1
type: string
bufferMaxRequestBytes:
description: |-
Sets the max_request_bytes value for the http.buffer filter.
If the value is 0, it skips adding a Buffer filter into the filter chain.
format: int32
type: integer
port:
description: Defines an Envoy listener Port.
type: integer
Expand All @@ -3952,6 +3970,12 @@ spec:
description: Defines an Envoy Listener Address.
minLength: 1
type: string
bufferMaxRequestBytes:
description: |-
Sets the max_request_bytes value for the http.buffer filter.
If the value is 0, it skips adding a Buffer filter into the filter chain.
format: int32
type: integer
port:
description: Defines an Envoy listener Port.
type: integer
Expand Down
24 changes: 24 additions & 0 deletions examples/render/contour-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,12 @@ spec:
description: Defines an Envoy Listener Address.
minLength: 1
type: string
bufferMaxRequestBytes:
description: |-
Sets the max_request_bytes value for the http.buffer filter.
If the value is 0, it skips adding a Buffer filter into the filter chain.
format: int32
type: integer
port:
description: Defines an Envoy listener Port.
type: integer
Expand All @@ -487,6 +493,12 @@ spec:
description: Defines an Envoy Listener Address.
minLength: 1
type: string
bufferMaxRequestBytes:
description: |-
Sets the max_request_bytes value for the http.buffer filter.
If the value is 0, it skips adding a Buffer filter into the filter chain.
format: int32
type: integer
port:
description: Defines an Envoy listener Port.
type: integer
Expand Down Expand Up @@ -4155,6 +4167,12 @@ spec:
description: Defines an Envoy Listener Address.
minLength: 1
type: string
bufferMaxRequestBytes:
description: |-
Sets the max_request_bytes value for the http.buffer filter.
If the value is 0, it skips adding a Buffer filter into the filter chain.
format: int32
type: integer
port:
description: Defines an Envoy listener Port.
type: integer
Expand All @@ -4172,6 +4190,12 @@ spec:
description: Defines an Envoy Listener Address.
minLength: 1
type: string
bufferMaxRequestBytes:
description: |-
Sets the max_request_bytes value for the http.buffer filter.
If the value is 0, it skips adding a Buffer filter into the filter chain.
format: int32
type: integer
port:
description: Defines an Envoy listener Port.
type: integer
Expand Down
24 changes: 24 additions & 0 deletions examples/render/contour-gateway-provisioner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,12 @@ spec:
description: Defines an Envoy Listener Address.
minLength: 1
type: string
bufferMaxRequestBytes:
description: |-
Sets the max_request_bytes value for the http.buffer filter.
If the value is 0, it skips adding a Buffer filter into the filter chain.
format: int32
type: integer
port:
description: Defines an Envoy listener Port.
type: integer
Expand All @@ -278,6 +284,12 @@ spec:
description: Defines an Envoy Listener Address.
minLength: 1
type: string
bufferMaxRequestBytes:
description: |-
Sets the max_request_bytes value for the http.buffer filter.
If the value is 0, it skips adding a Buffer filter into the filter chain.
format: int32
type: integer
port:
description: Defines an Envoy listener Port.
type: integer
Expand Down Expand Up @@ -3946,6 +3958,12 @@ spec:
description: Defines an Envoy Listener Address.
minLength: 1
type: string
bufferMaxRequestBytes:
description: |-
Sets the max_request_bytes value for the http.buffer filter.
If the value is 0, it skips adding a Buffer filter into the filter chain.
format: int32
type: integer
port:
description: Defines an Envoy listener Port.
type: integer
Expand All @@ -3963,6 +3981,12 @@ spec:
description: Defines an Envoy Listener Address.
minLength: 1
type: string
bufferMaxRequestBytes:
description: |-
Sets the max_request_bytes value for the http.buffer filter.
If the value is 0, it skips adding a Buffer filter into the filter chain.
format: int32
type: integer
port:
description: Defines an Envoy listener Port.
type: integer
Expand Down
24 changes: 24 additions & 0 deletions examples/render/contour-gateway.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,12 @@ spec:
description: Defines an Envoy Listener Address.
minLength: 1
type: string
bufferMaxRequestBytes:
description: |-
Sets the max_request_bytes value for the http.buffer filter.
If the value is 0, it skips adding a Buffer filter into the filter chain.
format: int32
type: integer
port:
description: Defines an Envoy listener Port.
type: integer
Expand All @@ -303,6 +309,12 @@ spec:
description: Defines an Envoy Listener Address.
minLength: 1
type: string
bufferMaxRequestBytes:
description: |-
Sets the max_request_bytes value for the http.buffer filter.
If the value is 0, it skips adding a Buffer filter into the filter chain.
format: int32
type: integer
port:
description: Defines an Envoy listener Port.
type: integer
Expand Down Expand Up @@ -3971,6 +3983,12 @@ spec:
description: Defines an Envoy Listener Address.
minLength: 1
type: string
bufferMaxRequestBytes:
description: |-
Sets the max_request_bytes value for the http.buffer filter.
If the value is 0, it skips adding a Buffer filter into the filter chain.
format: int32
type: integer
port:
description: Defines an Envoy listener Port.
type: integer
Expand All @@ -3988,6 +4006,12 @@ spec:
description: Defines an Envoy Listener Address.
minLength: 1
type: string
bufferMaxRequestBytes:
description: |-
Sets the max_request_bytes value for the http.buffer filter.
If the value is 0, it skips adding a Buffer filter into the filter chain.
format: int32
type: integer
port:
description: Defines an Envoy listener Port.
type: integer
Expand Down
24 changes: 24 additions & 0 deletions examples/render/contour.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,12 @@ spec:
description: Defines an Envoy Listener Address.
minLength: 1
type: string
bufferMaxRequestBytes:
description: |-
Sets the max_request_bytes value for the http.buffer filter.
If the value is 0, it skips adding a Buffer filter into the filter chain.
format: int32
type: integer
port:
description: Defines an Envoy listener Port.
type: integer
Expand All @@ -487,6 +493,12 @@ spec:
description: Defines an Envoy Listener Address.
minLength: 1
type: string
bufferMaxRequestBytes:
description: |-
Sets the max_request_bytes value for the http.buffer filter.
If the value is 0, it skips adding a Buffer filter into the filter chain.
format: int32
type: integer
port:
description: Defines an Envoy listener Port.
type: integer
Expand Down Expand Up @@ -4155,6 +4167,12 @@ spec:
description: Defines an Envoy Listener Address.
minLength: 1
type: string
bufferMaxRequestBytes:
description: |-
Sets the max_request_bytes value for the http.buffer filter.
If the value is 0, it skips adding a Buffer filter into the filter chain.
format: int32
type: integer
port:
description: Defines an Envoy listener Port.
type: integer
Expand All @@ -4172,6 +4190,12 @@ spec:
description: Defines an Envoy Listener Address.
minLength: 1
type: string
bufferMaxRequestBytes:
description: |-
Sets the max_request_bytes value for the http.buffer filter.
If the value is 0, it skips adding a Buffer filter into the filter chain.
format: int32
type: integer
port:
description: Defines an Envoy listener Port.
type: integer
Expand Down
14 changes: 8 additions & 6 deletions internal/contourconfig/contourconfiguration.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,16 @@ func Defaults() contour_v1alpha1.ContourConfigurationSpec {
Name: "envoy",
},
HTTPListener: &contour_v1alpha1.EnvoyListener{
Address: "0.0.0.0",
Port: 8080,
AccessLog: "/dev/stdout",
Address: "0.0.0.0",
Port: 8080,
AccessLog: "/dev/stdout",
BufferMaxRequestBytes: 0,
},
HTTPSListener: &contour_v1alpha1.EnvoyListener{
Address: "0.0.0.0",
Port: 8443,
AccessLog: "/dev/stdout",
Address: "0.0.0.0",
Port: 8443,
AccessLog: "/dev/stdout",
BufferMaxRequestBytes: 0,
},
Health: &contour_v1alpha1.HealthConfig{
Address: "0.0.0.0",
Expand Down
14 changes: 8 additions & 6 deletions internal/contourconfig/contourconfiguration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,16 @@ func TestOverlayOnDefaults(t *testing.T) {
Name: "coolname",
},
HTTPListener: &contour_v1alpha1.EnvoyListener{
Address: "3.4.5.6",
Port: 8989,
AccessLog: "/dev/oops",
Address: "3.4.5.6",
Port: 8989,
AccessLog: "/dev/oops",
BufferMaxRequestBytes: 10,
},
HTTPSListener: &contour_v1alpha1.EnvoyListener{
Address: "4.5.6.7",
Port: 8445,
AccessLog: "/dev/oops",
Address: "4.5.6.7",
Port: 8445,
AccessLog: "/dev/oops",
BufferMaxRequestBytes: 10,
},
Health: &contour_v1alpha1.HealthConfig{
Address: "1.1.1.1",
Expand Down
Loading