Skip to content

Commit 00ec6a2

Browse files
author
Andrew Farries
committed
Pre-flight requests to server /api/* endpoints
Before serving /api requests, make a 'pre-flight' request to `/api/feature-flags/slow-database` and use the `X-Gitpod-Slow-Database` header in the response to decide where to send the actual request; either to the regular `server` service or the new `slow-server` service.
1 parent 79e4e37 commit 00ec6a2

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

components/proxy/conf/Caddyfile

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,30 @@ https://{$GITPOD_DOMAIN} {
235235
base_domain {$GITPOD_DOMAIN}
236236
}
237237

238-
# note: no compression, as that breaks streaming for headless logs
238+
forward_auth server.{$KUBE_NAMESPACE}.{$KUBE_DOMAIN}:3000 {
239+
uri /feature-flags/slow-database
240+
copy_headers X-Gitpod-Slow-Database
241+
}
242+
243+
@slow {
244+
header X-Gitpod-Slow-Database "true"
245+
}
246+
247+
@fast {
248+
not header X-Gitpod-Slow-Database "true"
249+
}
239250

240251
uri strip_prefix /api
241-
reverse_proxy server.{$KUBE_NAMESPACE}.{$KUBE_DOMAIN}:3000 {
252+
253+
reverse_proxy @fast server.{$KUBE_NAMESPACE}.{$KUBE_DOMAIN}:3000 {
254+
import upstream_headers
255+
import upstream_connection
256+
257+
# required for smooth streaming of terminal logs
258+
flush_interval -1
259+
}
260+
261+
reverse_proxy @slow slow-server.{$KUBE_NAMESPACE}.{$KUBE_DOMAIN}:3000 {
242262
import upstream_headers
243263
import upstream_connection
244264

0 commit comments

Comments
 (0)