Skip to content

Commit

Permalink
Add proxy_send_timeout to configmap and annot
Browse files Browse the repository at this point in the history
  • Loading branch information
LorcanMcVeigh authored Jul 8, 2019
1 parent f87aacb commit 1f4ad60
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/configmap-and-annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. | |
Expand Down
2 changes: 1 addition & 1 deletion docs/virtualserver-and-virtualserverroute.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions internal/configs/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -151,6 +152,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)
Expand Down
4 changes: 4 additions & 0 deletions internal/configs/configmaps.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions internal/configs/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion internal/configs/ingress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -161,6 +161,7 @@ func createExpectedConfigForCafeIngressEx() version1.IngressNginxConfig {
Upstream: coffeeUpstream,
ProxyConnectTimeout: "60s",
ProxyReadTimeout: "60s",
ProxySendTimeout: "60s",
ClientMaxBodySize: "1m",
ProxyBuffering: true,
},
Expand All @@ -169,6 +170,7 @@ func createExpectedConfigForCafeIngressEx() version1.IngressNginxConfig {
Upstream: teaUpstream,
ProxyConnectTimeout: "60s",
ProxyReadTimeout: "60s",
ProxySendTimeout: "60s",
ClientMaxBodySize: "1m",
ProxyBuffering: true,
},
Expand Down Expand Up @@ -510,6 +512,7 @@ func createExpectedConfigForMergeableCafeIngress() version1.IngressNginxConfig {
Upstream: coffeeUpstream,
ProxyConnectTimeout: "60s",
ProxyReadTimeout: "60s",
ProxySendTimeout: "60s",
ClientMaxBodySize: "1m",
ProxyBuffering: true,
MinionIngress: &version1.Ingress{
Expand All @@ -526,6 +529,7 @@ func createExpectedConfigForMergeableCafeIngress() version1.IngressNginxConfig {
Upstream: teaUpstream,
ProxyConnectTimeout: "60s",
ProxyReadTimeout: "60s",
ProxySendTimeout: "60s",
ClientMaxBodySize: "1m",
ProxyBuffering: true,
MinionIngress: &version1.Ingress{
Expand Down
1 change: 1 addition & 0 deletions internal/configs/version1/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ type Location struct {
Upstream Upstream
ProxyConnectTimeout string
ProxyReadTimeout string
ProxySendTimeout string
ClientMaxBodySize string
Websocket bool
Rewrite string
Expand Down
2 changes: 2 additions & 0 deletions internal/configs/version1/nginx-plus.ingress.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions internal/configs/version1/nginx.ingress.tmpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# configuration for {{.Ingress.Namespace}}/{{.Ingress.Name}}

{{range $upstream := .Upstreams}}
upstream {{$upstream.Name}} {
{{if $upstream.LBMethod }}{{$upstream.LBMethod}};{{end}}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions internal/configs/version1/templates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ var ingCfg = IngressNginxConfig{
Upstream: testUps,
ProxyConnectTimeout: "10s",
ProxyReadTimeout: "10s",
ProxySendTimeout: "10s",
ClientMaxBodySize: "2m",
JWTAuth: &JWTAuth{
Key: "/etc/nginx/secrets/location-key.jwk",
Expand Down

0 comments on commit 1f4ad60

Please sign in to comment.