Search code examples
istioenvoyproxy

Can envoy header x-envoy-upstream-rq-timeout-ms be used in curl directly?


I tested a sending http request with x-envoy-upstream-rq-timeout-ms header between istio installed pod. envoy proxy

I expected that request fails because of very small timeout-ms (1ms). It is shorter than actual upstream service time in the response header. x-envoy-upstream-service-time: 5

root@nginx:/# curl -v -H "x-envoy-upstream-rq-timeout-ms: 1" 'http://http-echo-svc.circuit-breaker/200'
*   Trying 172.20.236.72:80...
* Connected to http-echo-svc.circuit-breaker (172.20.236.72) port 80 (#0)
> GET /200 HTTP/1.1
> Host: http-echo-svc.circuit-breaker
> User-Agent: curl/7.74.0
> Accept: */*
> x-envoy-upstream-rq-timeout-ms: 1
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< content-length: 0
< date: Mon, 07 Aug 2023 07:21:48 GMT
< x-envoy-upstream-service-time: 5
< server: envoy
<
* Connection #0 to host http-echo-svc.circuit-breaker left intact

As you can see request is not timed out. Any problem in my test?


Solution

  • The header "x-envoy-upstream-rq-timeout-ms" will certainly work. it will gateway timeout error.

    Please ensure the timeout value in virtual service is not set to "0" like below. This will disable the timeout. More details are in envoy documentation

    http:
      - route:
        - destination:
            host: reviews        
        timeout: 0
    

    Looks like the curl request is being made from inside the pod. the curl request from inside the pod doesn't have the header effect.

    When the curl request is made from outside pod with ""x-envoy-upstream-rq-timeout-ms" you should see below output for the curl request.

    < HTTP/1.1 504 Gateway Timeout
    < content-length: 0
    < date: Mon, 07 Aug 2023 07:21:48 GMT
    < x-envoy-upstream-service-time: 5
    < server: istio-envoy