Skip to content
Merged
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
4 changes: 3 additions & 1 deletion internal/ingress/annotations/proxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,11 @@ func (a proxy) Parse(ing *networking.Ingress) (interface{}, error) {
config.BufferSize = defBackend.ProxyBufferSize
}

// Only set BusyBuffersSize if annotation is present, blank is NGINX default
// https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_busy_buffers_size
config.BusyBuffersSize, err = parser.GetStringAnnotation(proxyBusyBuffersSizeAnnotation, ing, a.annotationConfig.Annotations)
if err != nil {
config.BusyBuffersSize = defBackend.ProxyBusyBuffersSize
config.BusyBuffersSize = ""
}

config.CookiePath, err = parser.GetStringAnnotation(proxyCookiePathAnnotation, ing, a.annotationConfig.Annotations)
Expand Down
25 changes: 22 additions & 3 deletions internal/ingress/annotations/proxy/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,9 @@ func TestProxyWithNoAnnotation(t *testing.T) {
if !ok {
t.Fatalf("expected a Config type")
}
if p.BusyBuffersSize != "" {
t.Errorf("expected empty BusyBuffersSize but returned %v", p.BusyBuffersSize)
}
if p.ConnectTimeout != 10 {
t.Errorf("expected 10 as connect-timeout but returned %v", p.ConnectTimeout)
}
Expand All @@ -273,9 +276,6 @@ func TestProxyWithNoAnnotation(t *testing.T) {
if p.BufferSize != "10k" {
t.Errorf("expected 10k as buffer-size but returned %v", p.BufferSize)
}
if p.BusyBuffersSize != "15k" {
t.Errorf("expected 15k as buffer-size but returned %v", p.BusyBuffersSize)
}
if p.BodySize != "3k" {
t.Errorf("expected 3k as body-size but returned %v", p.BodySize)
}
Expand All @@ -298,3 +298,22 @@ func TestProxyWithNoAnnotation(t *testing.T) {
t.Errorf("expected 1024m as proxy-max-temp-file-size but returned %v", p.ProxyMaxTempFileSize)
}
}

// Add a test for when annotation is set
func TestProxyWithBusyBuffersSizeAnnotation(t *testing.T) {
ing := buildIngress()
data := map[string]string{}
data[parser.GetAnnotationWithPrefix("proxy-busy-buffers-size")] = "4k"
ing.SetAnnotations(data)
i, err := NewParser(mockBackend{}).Parse(ing)
if err != nil {
t.Fatalf("unexpected error parsing a valid")
}
p, ok := i.(*Config)
if !ok {
t.Fatalf("expected a Config type")
}
if p.BusyBuffersSize != "4k" {
t.Errorf("expected 4k as BusyBuffersSize but returned %v", p.BusyBuffersSize)
}
}
4 changes: 4 additions & 0 deletions rootfs/etc/nginx/template/nginx.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,9 @@ stream {
{{ end }}
proxy_buffer_size {{ $location.Proxy.BufferSize }};
proxy_buffers {{ $location.Proxy.BuffersNumber }} {{ $location.Proxy.BufferSize }};
{{ if $location.Proxy.BusyBuffersSize }}
proxy_busy_buffers_size {{ $location.Proxy.BusyBuffersSize }};
{{ end }}
proxy_request_buffering {{ $location.Proxy.RequestBuffering }};

proxy_ssl_server_name on;
Expand Down Expand Up @@ -1334,7 +1336,9 @@ stream {
proxy_buffering {{ $location.Proxy.ProxyBuffering }};
proxy_buffer_size {{ $location.Proxy.BufferSize }};
proxy_buffers {{ $location.Proxy.BuffersNumber }} {{ $location.Proxy.BufferSize }};
{{ if $location.Proxy.BusyBuffersSize }}
proxy_busy_buffers_size {{ $location.Proxy.BusyBuffersSize }};
{{ end }}
{{ if isValidByteSize $location.Proxy.ProxyMaxTempFileSize true }}
proxy_max_temp_file_size {{ $location.Proxy.ProxyMaxTempFileSize }};
{{ end }}
Expand Down