envoyproxy / envoyproxy/envoy-mobile
Request Filters for Request's Retries
- Dominant language
- Java
- Stars
- 566
- Forks
- 85
- PR merge metrics
- No merged PRs in 30d
Description
## Proposal
Allow `EnvoyMobile` request filters to be run for each retry request it performs.
## Introduction
Currently, `EnvoyMobile`'s request filter chain is run only once for any network request it performs. This is true even for requests with multiple retries.
Let's say that we have a retry policy that allows for up to 3 retries of a request and mark these attempts using `0`, `1`, `2`, `3` numbers. Now, before a request is performed `EnvoyMobile` allows us to modify it using registered filters. We can modify the request once before the attempt `0` is made and allow `EnvoyMobile` to perform attempts `1`, `2` and `3` as needed without being able to modify requests that are made as part of these retries.
## Issue
At Lyft, we work on extending our mobile fault injection capabilities. For this reason, we work actively on ingesting 'fault injection HTTP headers' into random network requests our mobile applications perform in order to understand the behavior of our apps in degraded server and/or connectivity conditions. Fault injection HTTP headers are just special HTTP headers supported by `Envoy` that's used by Lyft's server infrastructure. They are documented [here](https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_filters/fault_filter#controlling-fault-injection-via-http-headers) and they include the following headers: `x-envoy-fault-request-abort`, `x-envoy-fault-delay-request` and `x-envoy-fault-response-limit`.
What is explained below is true for all of these headers but let's look at `x-envoy-fault-request-abort` headers specifically because its example outlines the issue we are dealing with the best. Let's say that we have a request `v1/foo` and we want to check how our application behaves in cases where 50% of requests of this type failing with 400 HTTP status code.
We can use `EnvoyMobile` filter chain to add `x-envoy-fault-abort-request` HTTP header and set its value to `400`. The problem is that we cannot specify that these HTTP headers should be added to 50% of outgoing requests only - we can either not add it to a request at all or add it and accept the fact that it's going to be added to the original request and all of its retries.
Going back to our example, we want to simulate 50% failure rate with 400 status code for 50% of `v1/foo` network requests and our default retry policy allows for up to 3 retries of any request. With the current capabilities of `EnvoyMobile` we can add `x-envoy-fault-abort-request: 400` HTTP header to outgoing network request (with 50% chance of it being added) but in the end, we end up with 4 attempts of this request failing with 400 status code since each of the retries of the request contains `x-envoy-fault-abort-request: 400` HTTP header.
This makes it impossible for us to test scenarios in which only a portion of attempts of performing a given request fails with a given status code.
Contributor guide
Assessment
This issue has not been assessed yet.