Skip to content

Commit 8d10bf6

Browse files
committed
fix(router): increase timeouts and survive controller/builder failures
Bumps the timeouts to 20 minutes and wraps the builder and controller proxies in `if` clauses to prevent the router from crashing when either controller or builder are restarted. Also adds a generic health-check URL to be used for load balancers, and an X-Deis-Upstream header. TESTIING: rebuild and restart the router: ```console $ make -C router/ build restart ``` closes #1096, #1098, #1078, #1081 replaces #1080, #1057
1 parent f8f0ae2 commit 8d10bf6

2 files changed

Lines changed: 35 additions & 16 deletions

File tree

docs/operations/configure-load-balancers.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ You can proceed with the next section: :ref:`configure-dns`.
1111

1212
On a multi-node cluster, however, there are probably multiple routers scheduled to the cluster, and
1313
these can potentially move hosts. Therefore, it is recommended that you configure a load balancer
14-
to operate in front of the Deis cluster to serve application traffic. A simple configuration is one
15-
that has all Deis machines listed in its configuration file, but a host is only considered 'healthy'
16-
when it is responding to ports 80 and 2222. This enables the load balancer to serve trafic to whichever
17-
hosts happen to be running the deis-router component at any one time.
14+
to operate in front of the Deis cluster to serve application traffic.
1815

1916
These ports need to be open on the load balancers:
2017

@@ -24,3 +21,8 @@ These ports need to be open on the load balancers:
2421
Optionally, you can also open port 443 and configure SSL termination on the load balancers, but
2522
requests should still be forwarded to port 80 on the routers. Communication between Deis components
2623
is currently unencrypted.
24+
25+
A health check should be configured on the load balancer to send an HTTP request to /health-check at
26+
port 80 on all nodes in the Deis cluster. The health check endpoint returns an HTTP 200. This enables
27+
the load balancer to serve trafic to whichever hosts happen to be running the deis-router component
28+
at any moment.

router/templates/nginx.conf

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@ http {
3434
access_log /dev/stdout;
3535
error_log /dev/stdout;
3636

37+
## start deis-controller
38+
{{ if .deis_controller_host }}
3739
upstream deis-controller {
3840
server {{ .deis_controller_host }}:{{ .deis_controller_port }};
3941
}
4042

4143
server {
42-
listen 80 default_server;
4344
server_name ~^deis\.(?<domain>.+)$;
4445
server_name_in_redirect off;
4546
port_in_redirect off;
@@ -50,14 +51,15 @@ http {
5051
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
5152
proxy_redirect off;
5253
proxy_connect_timeout 10s;
53-
proxy_send_timeout 30s;
54-
proxy_read_timeout 30s;
54+
proxy_send_timeout 1200s;
55+
proxy_read_timeout 1200s;
5556

5657
proxy_pass http://deis-controller;
5758
}
58-
}
59+
}{{ end }}
60+
## end deis-controller
5961

60-
# service definitions for each application
62+
## start service definitions for each application
6163
{{ $domains := .deis_domains }}{{ range $service := .deis_services }}{{ if $service.Nodes }}
6264
upstream {{ Base $service.Key }} {
6365
{{ range $upstream := $service.Nodes }}server {{ $upstream.Value }};
@@ -76,24 +78,39 @@ http {
7678
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
7779
proxy_redirect off;
7880
proxy_connect_timeout 10s;
79-
proxy_send_timeout 30s;
80-
proxy_read_timeout 30s;
81+
proxy_send_timeout 1200s;
82+
proxy_read_timeout 1200s;
83+
84+
add_header X-Deis-Upstream $upstream_addr;
8185

8286
proxy_pass http://{{ Base $service.Key }};
8387
}
8488
}
8589
{{ end }}{{ end }}
90+
## end service definitions for each application
91+
92+
# healthcheck
93+
server {
94+
listen 80 default_server;
95+
location /health-check {
96+
default_type 'text/plain';
97+
access_log off;
98+
return 200;
99+
}
100+
}
86101
}
87102

103+
## start builder
104+
{{ if .deis_builder_host }}
88105
tcp {
89106
access_log /dev/stdout;
90107
tcp_nodelay on;
91-
timeout 30000;
108+
timeout 1200000;
92109

93110
# same directive names, but these are in miliseconds...
94111
proxy_connect_timeout 10000;
95-
proxy_send_timeout 30000;
96-
proxy_read_timeout 30000;
112+
proxy_send_timeout 1200000;
113+
proxy_read_timeout 1200000;
97114

98115
upstream builder {
99116
server {{ .deis_builder_host }}:{{ .deis_builder_port }};
@@ -103,5 +120,5 @@ tcp {
103120
listen 2222;
104121
proxy_pass builder;
105122
}
106-
}
107-
123+
}{{ end }}
124+
## end builder

0 commit comments

Comments
 (0)