From 27706c9a480922068309a6bfd5e0f834f7199b24 Mon Sep 17 00:00:00 2001 From: LorcanMcVeigh Date: Fri, 28 Jun 2019 10:27:09 +0100 Subject: [PATCH] Added proxy_send_timeout to configmap and annot --- docs/configmap-and-annotations.md | 1 + docs/virtualserver-and-virtualserverroute.md | 2 +- internal/configs/annotations.go | 5 +++++ internal/configs/configmaps.go | 4 ++++ internal/configs/ingress.go | 1 + internal/configs/ingress_test.go | 6 +++++- internal/configs/version1/config.go | 1 + internal/configs/version1/nginx-plus.ingress.tmpl | 2 ++ internal/configs/version1/nginx.ingress.tmpl | 3 +++ internal/configs/version1/templates_test.go | 1 + 10 files changed, 24 insertions(+), 2 deletions(-) diff --git a/docs/configmap-and-annotations.md b/docs/configmap-and-annotations.md index 9c1a666d71..cf0faffbd6 100644 --- a/docs/configmap-and-annotations.md +++ b/docs/configmap-and-annotations.md @@ -85,6 +85,7 @@ spec: | ---------- | -------------- | ----------- | ------- | ------- | | `nginx.org/proxy-connect-timeout` | `proxy-connect-timeout` | Sets the value of the [proxy_connect_timeout](http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_connect_timeout) and [grpc_connect_timeout](http://nginx.org/en/docs/http/ngx_http_grpc_module.html#grpc_connect_timeout) directive. | `60s` | | | `nginx.org/proxy-read-timeout` | `proxy-read-timeout` | Sets the value of the [proxy_read_timeout](http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_read_timeout) and [grpc_read_timeout](http://nginx.org/en/docs/http/ngx_http_grpc_module.html#grpc_read_timeout) directive. | `60s` | | +| `nginx.org/proxy-send-timeout` | `proxy-send-timeout` | Sets the value of the [proxy_send_timeout](http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_send_timeout) and [grpc_send_timeout](http://nginx.org/en/docs/http/ngx_http_grpc_module.html#grpc_send_timeout) directive. | `60s` | | | `nginx.org/client-max-body-size` | `client-max-body-size` | Sets the value of the [client_max_body_size](http://nginx.org/en/docs/http/ngx_http_core_module.html#client_max_body_size) directive. | `1m` | | | `nginx.org/proxy-buffering` | `proxy-buffering` | Enables or disables [buffering of responses](http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_buffering) from the proxied server. | `True` | | | `nginx.org/proxy-buffers` | `proxy-buffers` | Sets the value of the [proxy_buffers](http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_buffers) directive. | Depends on the platform. | | diff --git a/docs/virtualserver-and-virtualserverroute.md b/docs/virtualserver-and-virtualserverroute.md index cf7a9dc8f3..fe33c974ce 100644 --- a/docs/virtualserver-and-virtualserverroute.md +++ b/docs/virtualserver-and-virtualserverroute.md @@ -194,7 +194,7 @@ send-timeout: 30s | `max-fails` | The number of unsuccessful attempts to communicate with an upstream server that should happen in the duration set by the `fail-timeout` to consider the server unavailable. See the [max_fails](https://nginx.org/en/docs/http/ngx_http_upstream_module.html#max_fails) parameter of the server directive. The default is set in the `max-fails` ConfgMap key. | `int` | No | `connect-timeout` | The timeout for establishing a connection with an upstream server. See the [proxy_connect_timeout](https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_connect_timeout) directive. The default is specified in the `proxy-connect-timeout` ConfigMap key. | `string` | No `read-timeout` | The timeout for reading a response from an upstream server. See the [proxy_read_timeout](https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_read_timeout) directive. The default is specified in the `proxy-read-timeout` ConfigMap key. | `string` | No -`send-timeout` | The timeout for transmitting a request to an upstream server. See the [proxy_send_timeout](https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_send_timeout) directive. The default is `60s`. | `string` | No +`send-timeout` | The timeout for transmitting a request to an upstream server. See the [proxy_send_timeout](https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_send_timeout) directive. The default is specified in the `proxy-send-timeout` ConfigMap key. | `string` | No ### Split diff --git a/internal/configs/annotations.go b/internal/configs/annotations.go index eb70529f56..babf7ca911 100644 --- a/internal/configs/annotations.go +++ b/internal/configs/annotations.go @@ -39,6 +39,7 @@ var minionBlacklist = map[string]bool{ var minionInheritanceList = map[string]bool{ "nginx.org/proxy-connect-timeout": true, "nginx.org/proxy-read-timeout": true, + "nginx.org/proxy-send-timeout": true, "nginx.org/client-max-body-size": true, "nginx.org/proxy-buffering": true, "nginx.org/proxy-buffers": true, @@ -150,6 +151,10 @@ func parseAnnotations(ingEx *IngressEx, baseCfgParams *ConfigParams, isPlus bool cfgParams.ProxyReadTimeout = proxyReadTimeout } + if proxySendTimeout, exists := ingEx.Ingress.Annotations["nginx.org/proxy-send-timeout"]; exists { + cfgParams.ProxySendTimeout = proxySendTimeout + } + if proxyHideHeaders, exists, err := GetMapKeyAsStringSlice(ingEx.Ingress.Annotations, "nginx.org/proxy-hide-headers", ingEx.Ingress, ","); exists { if err != nil { glog.Error(err) diff --git a/internal/configs/configmaps.go b/internal/configs/configmaps.go index 61a60b2f19..aa560df186 100644 --- a/internal/configs/configmaps.go +++ b/internal/configs/configmaps.go @@ -51,6 +51,10 @@ func ParseConfigMap(cfgm *v1.ConfigMap, nginxPlus bool) *ConfigParams { cfgParams.ProxyReadTimeout = proxyReadTimeout } + if proxySendTimeout, exists := cfgm.Data["proxy-send-timeout"]; exists { + cfgParams.ProxySendTimeout = proxySendTimeout + } + if proxyHideHeaders, exists, err := GetMapKeyAsStringSlice(cfgm.Data, "proxy-hide-headers", cfgm, ","); exists { if err != nil { glog.Error(err) diff --git a/internal/configs/ingress.go b/internal/configs/ingress.go index a87ad5b2fd..4274448113 100644 --- a/internal/configs/ingress.go +++ b/internal/configs/ingress.go @@ -235,6 +235,7 @@ func createLocation(path string, upstream version1.Upstream, cfg *ConfigParams, Upstream: upstream, ProxyConnectTimeout: cfg.ProxyConnectTimeout, ProxyReadTimeout: cfg.ProxyReadTimeout, + ProxySendTimeout: cfg.ProxySendTimeout, ClientMaxBodySize: cfg.ClientMaxBodySize, Websocket: websocket, Rewrite: rewrite, diff --git a/internal/configs/ingress_test.go b/internal/configs/ingress_test.go index cc1b415434..ac957be713 100644 --- a/internal/configs/ingress_test.go +++ b/internal/configs/ingress_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/nginxinc/kubernetes-ingress/internal/configs/version1" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" "k8s.io/api/extensions/v1beta1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" @@ -161,6 +161,7 @@ func createExpectedConfigForCafeIngressEx() version1.IngressNginxConfig { Upstream: coffeeUpstream, ProxyConnectTimeout: "60s", ProxyReadTimeout: "60s", + ProxySendTimeout: "60s", ClientMaxBodySize: "1m", ProxyBuffering: true, }, @@ -169,6 +170,7 @@ func createExpectedConfigForCafeIngressEx() version1.IngressNginxConfig { Upstream: teaUpstream, ProxyConnectTimeout: "60s", ProxyReadTimeout: "60s", + ProxySendTimeout: "60s", ClientMaxBodySize: "1m", ProxyBuffering: true, }, @@ -510,6 +512,7 @@ func createExpectedConfigForMergeableCafeIngress() version1.IngressNginxConfig { Upstream: coffeeUpstream, ProxyConnectTimeout: "60s", ProxyReadTimeout: "60s", + ProxySendTimeout: "60s", ClientMaxBodySize: "1m", ProxyBuffering: true, MinionIngress: &version1.Ingress{ @@ -526,6 +529,7 @@ func createExpectedConfigForMergeableCafeIngress() version1.IngressNginxConfig { Upstream: teaUpstream, ProxyConnectTimeout: "60s", ProxyReadTimeout: "60s", + ProxySendTimeout: "60s", ClientMaxBodySize: "1m", ProxyBuffering: true, MinionIngress: &version1.Ingress{ diff --git a/internal/configs/version1/config.go b/internal/configs/version1/config.go index b219f05e24..66e9c15fa9 100644 --- a/internal/configs/version1/config.go +++ b/internal/configs/version1/config.go @@ -105,6 +105,7 @@ type Location struct { Upstream Upstream ProxyConnectTimeout string ProxyReadTimeout string + ProxySendTimeout string ClientMaxBodySize string Websocket bool Rewrite string diff --git a/internal/configs/version1/nginx-plus.ingress.tmpl b/internal/configs/version1/nginx-plus.ingress.tmpl index 4f17c6142c..d7c139e164 100644 --- a/internal/configs/version1/nginx-plus.ingress.tmpl +++ b/internal/configs/version1/nginx-plus.ingress.tmpl @@ -152,6 +152,7 @@ server { grpc_connect_timeout {{$location.ProxyConnectTimeout}}; grpc_read_timeout {{$location.ProxyReadTimeout}}; + grpc_send_timeout {{$location.ProxySendTimeout}}; grpc_set_header Host $host; grpc_set_header X-Real-IP $remote_addr; grpc_set_header X-Forwarded-For $proxy_add_x_forwarded_for; @@ -192,6 +193,7 @@ server { proxy_connect_timeout {{$location.ProxyConnectTimeout}}; proxy_read_timeout {{$location.ProxyReadTimeout}}; + proxy_send_timeout {{$location.ProxySendTimeout}}; client_max_body_size {{$location.ClientMaxBodySize}}; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; diff --git a/internal/configs/version1/nginx.ingress.tmpl b/internal/configs/version1/nginx.ingress.tmpl index 6a6aec19ec..dfe9a16494 100644 --- a/internal/configs/version1/nginx.ingress.tmpl +++ b/internal/configs/version1/nginx.ingress.tmpl @@ -1,4 +1,5 @@ # configuration for {{.Ingress.Namespace}}/{{.Ingress.Name}} + {{range $upstream := .Upstreams}} upstream {{$upstream.Name}} { {{if $upstream.LBMethod }}{{$upstream.LBMethod}};{{end}} @@ -102,6 +103,7 @@ server { grpc_connect_timeout {{$location.ProxyConnectTimeout}}; grpc_read_timeout {{$location.ProxyReadTimeout}}; + grpc_send_timeout {{$location.ProxySendTimeout}}; grpc_set_header Host $host; grpc_set_header X-Real-IP $remote_addr; grpc_set_header X-Forwarded-For $proxy_add_x_forwarded_for; @@ -134,6 +136,7 @@ server { proxy_connect_timeout {{$location.ProxyConnectTimeout}}; proxy_read_timeout {{$location.ProxyReadTimeout}}; + proxy_send_timeout {{$location.ProxySendTimeout}}; client_max_body_size {{$location.ClientMaxBodySize}}; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; diff --git a/internal/configs/version1/templates_test.go b/internal/configs/version1/templates_test.go index d13b71dafe..3b8c1c9e29 100644 --- a/internal/configs/version1/templates_test.go +++ b/internal/configs/version1/templates_test.go @@ -58,6 +58,7 @@ var ingCfg = IngressNginxConfig{ Upstream: testUps, ProxyConnectTimeout: "10s", ProxyReadTimeout: "10s", + ProxySendTimeout: "10s", ClientMaxBodySize: "2m", JWTAuth: &JWTAuth{ Key: "/etc/nginx/secrets/location-key.jwk",