Skip to content

Commit

Permalink
b/176912395: Automatically configure stream idle timeouts (#457)
Browse files Browse the repository at this point in the history
**Background**: See discussion in #455 

**Implementation**: When `deadline` is set in a backend rule, override the `stream_idle_timeout` for that operation to match the deadline. Created a flag `--stream_idle_timeout` to hold the default value and increase testability, but the flag is **not exposed** to the API producer.

The current solution fixes both cases:
1) Non-streaming HTTP requests over 5m will be supported by increasing the `deadline`. HTTP 408 will never be returned. Only HTTP 504 will occur once the configured deadline is met. 
2) For non-unary gRPC methods, user can configure the `deadline`. We disable request timeouts for streaming methods. Instead, `deadline` will configure stream idle time. So there is no need for the API Producer to set a flag.

Fixes #455
  • Loading branch information
nareddyt authored Jan 11, 2021
1 parent c9e6488 commit 114567e
Show file tree
Hide file tree
Showing 21 changed files with 815 additions and 49 deletions.
4 changes: 4 additions & 0 deletions examples/auth/envoy_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@
},
"route": {
"cluster": "backend-cluster-examples-auth.endpoints.cloudesf-testing.cloud.goog_local",
"idleTimeout": "300s",
"retryPolicy": {
"numRetries": 1,
"retryOn": "reset,connect-failure,refused-stream"
Expand Down Expand Up @@ -362,6 +363,7 @@
},
"route": {
"cluster": "backend-cluster-examples-auth.endpoints.cloudesf-testing.cloud.goog_local",
"idleTimeout": "300s",
"retryPolicy": {
"numRetries": 1,
"retryOn": "reset,connect-failure,refused-stream"
Expand Down Expand Up @@ -394,6 +396,7 @@
},
"route": {
"cluster": "backend-cluster-examples-auth.endpoints.cloudesf-testing.cloud.goog_local",
"idleTimeout": "300s",
"retryPolicy": {
"numRetries": 1,
"retryOn": "reset,connect-failure,refused-stream"
Expand Down Expand Up @@ -426,6 +429,7 @@
},
"route": {
"cluster": "backend-cluster-examples-auth.endpoints.cloudesf-testing.cloud.goog_local",
"idleTimeout": "300s",
"retryPolicy": {
"numRetries": 1,
"retryOn": "reset,connect-failure,refused-stream"
Expand Down
4 changes: 4 additions & 0 deletions examples/dynamic_routing/envoy_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@
"route": {
"cluster": "backend-cluster-http-bookstore-abc123456-uc.a.run.app:443",
"hostRewriteLiteral": "http-bookstore-abc123456-uc.a.run.app",
"idleTimeout": "300s",
"retryPolicy": {
"numRetries": 1,
"retryOn": "reset,connect-failure,refused-stream"
Expand Down Expand Up @@ -305,6 +306,7 @@
"route": {
"cluster": "backend-cluster-http-bookstore-abc123456-uc.a.run.app:443",
"hostRewriteLiteral": "http-bookstore-abc123456-uc.a.run.app",
"idleTimeout": "300s",
"retryPolicy": {
"numRetries": 1,
"retryOn": "reset,connect-failure,refused-stream"
Expand Down Expand Up @@ -342,6 +344,7 @@
"route": {
"cluster": "backend-cluster-http-bookstore-edf123456-uc.a.run.app:443",
"hostRewriteLiteral": "http-bookstore-edf123456-uc.a.run.app",
"idleTimeout": "300s",
"retryPolicy": {
"numRetries": 1,
"retryOn": "reset,connect-failure,refused-stream"
Expand Down Expand Up @@ -377,6 +380,7 @@
"route": {
"cluster": "backend-cluster-http-bookstore-edf123456-uc.a.run.app:443",
"hostRewriteLiteral": "http-bookstore-edf123456-uc.a.run.app",
"idleTimeout": "300s",
"retryPolicy": {
"numRetries": 1,
"retryOn": "reset,connect-failure,refused-stream"
Expand Down
30 changes: 22 additions & 8 deletions examples/grpc_dynamic_routing/envoy_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -908,11 +908,12 @@
"route": {
"cluster": "backend-cluster-grpc-echo-oxouww7xzq-uc.a.run.app:443",
"hostRewriteLiteral": "grpc-echo-oxouww7xzq-uc.a.run.app",
"idleTimeout": "401s",
"retryPolicy": {
"numRetries": 1,
"retryOn": "reset,connect-failure,refused-stream"
},
"timeout": "300s"
"timeout": "400s"
},
"typedPerFilterConfig": {
"com.google.espv2.filters.http.backend_auth": {
Expand Down Expand Up @@ -941,11 +942,12 @@
"route": {
"cluster": "backend-cluster-grpc-echo-oxouww7xzq-uc.a.run.app:443",
"hostRewriteLiteral": "grpc-echo-oxouww7xzq-uc.a.run.app",
"idleTimeout": "401s",
"retryPolicy": {
"numRetries": 1,
"retryOn": "reset,connect-failure,refused-stream"
},
"timeout": "300s"
"timeout": "400s"
},
"typedPerFilterConfig": {
"com.google.espv2.filters.http.backend_auth": {
Expand Down Expand Up @@ -974,11 +976,12 @@
"route": {
"cluster": "backend-cluster-grpc-echo-oxouww7xzq-uc.a.run.app:443",
"hostRewriteLiteral": "grpc-echo-oxouww7xzq-uc.a.run.app",
"idleTimeout": "401s",
"retryPolicy": {
"numRetries": 1,
"retryOn": "reset,connect-failure,refused-stream"
},
"timeout": "300s"
"timeout": "400s"
},
"typedPerFilterConfig": {
"com.google.espv2.filters.http.backend_auth": {
Expand Down Expand Up @@ -1007,11 +1010,12 @@
"route": {
"cluster": "backend-cluster-grpc-echo-oxouww7xzq-uc.a.run.app:443",
"hostRewriteLiteral": "grpc-echo-oxouww7xzq-uc.a.run.app",
"idleTimeout": "401s",
"retryPolicy": {
"numRetries": 1,
"retryOn": "reset,connect-failure,refused-stream"
},
"timeout": "300s"
"timeout": "400s"
},
"typedPerFilterConfig": {
"com.google.espv2.filters.http.backend_auth": {
Expand Down Expand Up @@ -1040,6 +1044,7 @@
"route": {
"cluster": "backend-cluster-grpc-echo-oxouww7xzq-uc.a.run.app:443",
"hostRewriteLiteral": "grpc-echo-oxouww7xzq-uc.a.run.app",
"idleTimeout": "400s",
"retryPolicy": {
"numRetries": 1,
"retryOn": "reset,connect-failure,refused-stream"
Expand Down Expand Up @@ -1077,6 +1082,7 @@
"route": {
"cluster": "backend-cluster-grpc-echo-oxouww7xzq-uc.a.run.app:443",
"hostRewriteLiteral": "grpc-echo-oxouww7xzq-uc.a.run.app",
"idleTimeout": "400s",
"retryPolicy": {
"numRetries": 1,
"retryOn": "reset,connect-failure,refused-stream"
Expand Down Expand Up @@ -1114,6 +1120,7 @@
"route": {
"cluster": "backend-cluster-grpc-echo-oxouww7xzq-uc.a.run.app:443",
"hostRewriteLiteral": "grpc-echo-oxouww7xzq-uc.a.run.app",
"idleTimeout": "400s",
"retryPolicy": {
"numRetries": 1,
"retryOn": "reset,connect-failure,refused-stream"
Expand Down Expand Up @@ -1147,6 +1154,7 @@
"route": {
"cluster": "backend-cluster-grpc-echo-oxouww7xzq-uc.a.run.app:443",
"hostRewriteLiteral": "grpc-echo-oxouww7xzq-uc.a.run.app",
"idleTimeout": "400s",
"retryPolicy": {
"numRetries": 1,
"retryOn": "reset,connect-failure,refused-stream"
Expand Down Expand Up @@ -1180,11 +1188,12 @@
"route": {
"cluster": "backend-cluster-grpc-echo-oxouww7xzq-uc.a.run.app:443",
"hostRewriteLiteral": "grpc-echo-oxouww7xzq-uc.a.run.app",
"idleTimeout": "401s",
"retryPolicy": {
"numRetries": 1,
"retryOn": "reset,connect-failure,refused-stream"
},
"timeout": "300s"
"timeout": "400s"
},
"typedPerFilterConfig": {
"com.google.espv2.filters.http.backend_auth": {
Expand Down Expand Up @@ -1213,11 +1222,12 @@
"route": {
"cluster": "backend-cluster-grpc-echo-oxouww7xzq-uc.a.run.app:443",
"hostRewriteLiteral": "grpc-echo-oxouww7xzq-uc.a.run.app",
"idleTimeout": "401s",
"retryPolicy": {
"numRetries": 1,
"retryOn": "reset,connect-failure,refused-stream"
},
"timeout": "300s"
"timeout": "400s"
},
"typedPerFilterConfig": {
"com.google.espv2.filters.http.backend_auth": {
Expand Down Expand Up @@ -1246,11 +1256,12 @@
"route": {
"cluster": "backend-cluster-grpc-echo-oxouww7xzq-uc.a.run.app:443",
"hostRewriteLiteral": "grpc-echo-oxouww7xzq-uc.a.run.app",
"idleTimeout": "401s",
"retryPolicy": {
"numRetries": 1,
"retryOn": "reset,connect-failure,refused-stream"
},
"timeout": "300s"
"timeout": "400s"
},
"typedPerFilterConfig": {
"com.google.espv2.filters.http.backend_auth": {
Expand Down Expand Up @@ -1279,11 +1290,12 @@
"route": {
"cluster": "backend-cluster-grpc-echo-oxouww7xzq-uc.a.run.app:443",
"hostRewriteLiteral": "grpc-echo-oxouww7xzq-uc.a.run.app",
"idleTimeout": "401s",
"retryPolicy": {
"numRetries": 1,
"retryOn": "reset,connect-failure,refused-stream"
},
"timeout": "300s"
"timeout": "400s"
},
"typedPerFilterConfig": {
"com.google.espv2.filters.http.backend_auth": {
Expand Down Expand Up @@ -1312,6 +1324,7 @@
"route": {
"cluster": "backend-cluster-grpc-echo-oxouww7xzq-uc.a.run.app:443",
"hostRewriteLiteral": "grpc-echo-oxouww7xzq-uc.a.run.app",
"idleTimeout": "400s",
"retryPolicy": {
"numRetries": 1,
"retryOn": "reset,connect-failure,refused-stream"
Expand Down Expand Up @@ -1349,6 +1362,7 @@
"route": {
"cluster": "backend-cluster-grpc-echo-oxouww7xzq-uc.a.run.app:443",
"hostRewriteLiteral": "grpc-echo-oxouww7xzq-uc.a.run.app",
"idleTimeout": "400s",
"retryPolicy": {
"numRetries": 1,
"retryOn": "reset,connect-failure,refused-stream"
Expand Down
2 changes: 1 addition & 1 deletion examples/grpc_dynamic_routing/grpc-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ backend:
- selector: "*"
address: "grpcs://grpc-echo-oxouww7xzq-uc.a.run.app"
jwt_audience: "https://grpc-echo-oxouww7xzq-uc.a.run.app"
deadline: 300
deadline: 400
8 changes: 4 additions & 4 deletions examples/grpc_dynamic_routing/service_config_generated.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,25 +88,25 @@
"rules": [
{
"address": "grpcs://grpc-echo-oxouww7xzq-uc.a.run.app",
"deadline": 300,
"deadline": 400,
"jwtAudience": "https://grpc-echo-oxouww7xzq-uc.a.run.app",
"selector": "test.grpc.Test.Echo"
},
{
"address": "grpcs://grpc-echo-oxouww7xzq-uc.a.run.app",
"deadline": 300,
"deadline": 400,
"jwtAudience": "https://grpc-echo-oxouww7xzq-uc.a.run.app",
"selector": "test.grpc.Test.EchoStream"
},
{
"address": "grpcs://grpc-echo-oxouww7xzq-uc.a.run.app",
"deadline": 300,
"deadline": 400,
"jwtAudience": "https://grpc-echo-oxouww7xzq-uc.a.run.app",
"selector": "test.grpc.Test.Cork"
},
{
"address": "grpcs://grpc-echo-oxouww7xzq-uc.a.run.app",
"deadline": 300,
"deadline": 400,
"jwtAudience": "https://grpc-echo-oxouww7xzq-uc.a.run.app",
"selector": "test.grpc.Test.EchoReport"
}
Expand Down
4 changes: 4 additions & 0 deletions examples/service_control/envoy_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,7 @@
},
"route": {
"cluster": "backend-cluster-examples-service-control.endpoints.cloudesf-testing.cloud.goog_local",
"idleTimeout": "300s",
"retryPolicy": {
"numRetries": 1,
"retryOn": "reset,connect-failure,refused-stream"
Expand Down Expand Up @@ -776,6 +777,7 @@
},
"route": {
"cluster": "backend-cluster-examples-service-control.endpoints.cloudesf-testing.cloud.goog_local",
"idleTimeout": "300s",
"retryPolicy": {
"numRetries": 1,
"retryOn": "reset,connect-failure,refused-stream"
Expand Down Expand Up @@ -804,6 +806,7 @@
},
"route": {
"cluster": "backend-cluster-examples-service-control.endpoints.cloudesf-testing.cloud.goog_local",
"idleTimeout": "300s",
"retryPolicy": {
"numRetries": 1,
"retryOn": "reset,connect-failure,refused-stream"
Expand Down Expand Up @@ -832,6 +835,7 @@
},
"route": {
"cluster": "backend-cluster-examples-service-control.endpoints.cloudesf-testing.cloud.goog_local",
"idleTimeout": "300s",
"retryPolicy": {
"numRetries": 1,
"retryOn": "reset,connect-failure,refused-stream"
Expand Down
8 changes: 8 additions & 0 deletions examples/testdata/route_match/envoy_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@
"route": {
"cluster": "backend-cluster-http-bookstore-edf123456-uc.a.run.app:443",
"hostRewriteLiteral": "http-bookstore-edf123456-uc.a.run.app",
"idleTimeout": "300s",
"retryPolicy": {
"numRetries": 1,
"retryOn": "reset,connect-failure,refused-stream"
Expand Down Expand Up @@ -311,6 +312,7 @@
"route": {
"cluster": "backend-cluster-http-bookstore-edf123456-uc.a.run.app:443",
"hostRewriteLiteral": "http-bookstore-edf123456-uc.a.run.app",
"idleTimeout": "300s",
"retryPolicy": {
"numRetries": 1,
"retryOn": "reset,connect-failure,refused-stream"
Expand Down Expand Up @@ -354,6 +356,7 @@
"route": {
"cluster": "backend-cluster-http-bookstore-abc9876-uc.a.run.app:443",
"hostRewriteLiteral": "http-bookstore-abc9876-uc.a.run.app",
"idleTimeout": "300s",
"retryPolicy": {
"numRetries": 1,
"retryOn": "reset,connect-failure,refused-stream"
Expand Down Expand Up @@ -390,6 +393,7 @@
"route": {
"cluster": "backend-cluster-http-bookstore-abc9876-uc.a.run.app:443",
"hostRewriteLiteral": "http-bookstore-abc9876-uc.a.run.app",
"idleTimeout": "300s",
"retryPolicy": {
"numRetries": 1,
"retryOn": "reset,connect-failure,refused-stream"
Expand Down Expand Up @@ -426,6 +430,7 @@
"route": {
"cluster": "backend-cluster-http-bookstore-abc9876-uc.a.run.app:443",
"hostRewriteLiteral": "http-bookstore-abc9876-uc.a.run.app",
"idleTimeout": "300s",
"retryPolicy": {
"numRetries": 1,
"retryOn": "reset,connect-failure,refused-stream"
Expand Down Expand Up @@ -462,6 +467,7 @@
"route": {
"cluster": "backend-cluster-http-bookstore-abc9876-uc.a.run.app:443",
"hostRewriteLiteral": "http-bookstore-abc9876-uc.a.run.app",
"idleTimeout": "300s",
"retryPolicy": {
"numRetries": 1,
"retryOn": "reset,connect-failure,refused-stream"
Expand Down Expand Up @@ -498,6 +504,7 @@
"route": {
"cluster": "backend-cluster-http-bookstore-abc9876-uc.a.run.app:443",
"hostRewriteLiteral": "http-bookstore-abc9876-uc.a.run.app",
"idleTimeout": "300s",
"retryPolicy": {
"numRetries": 1,
"retryOn": "reset,connect-failure,refused-stream"
Expand Down Expand Up @@ -534,6 +541,7 @@
"route": {
"cluster": "backend-cluster-http-bookstore-abc9876-uc.a.run.app:443",
"hostRewriteLiteral": "http-bookstore-abc9876-uc.a.run.app",
"idleTimeout": "300s",
"retryPolicy": {
"numRetries": 1,
"retryOn": "reset,connect-failure,refused-stream"
Expand Down
Loading

0 comments on commit 114567e

Please sign in to comment.