Fault injection filter

Requirements

Sandbox environment

Setup your sandbox environment with Docker and Docker Compose, and clone the Envoy repository with Git.

This simple example demonstrates Envoy’s fault injection capability using Envoy’s runtime support to control the feature.

It demonstrates fault injection that cause the request to abort and fail, and also faults that simply delay the response.

Step 1: Start all of our containers

Change to the examples/fault_injection directory.

Terminal 1

  1. $ pwd
  2. envoy/examples/fault-injection
  3. $ docker-compose pull
  4. $ docker-compose up --build -d
  5. $ docker-compose ps
  6. Name Command State Ports
  7. ------------------------------------------------------------------------------------------------------
  8. fault-injection_backend_1 gunicorn -b 0.0.0.0:80 htt Up 0.0.0.0:8080->80/tcp
  9. fault-injection_envoy_1 /docker-entrypoint.sh /usr Up 10000/tcp, 0.0.0.0:9211->9211/tcp

Step 2: Start sending continuous stream of HTTP requests

Terminal 2

  1. $ pwd
  2. envoy/examples/fault-injection
  3. $ docker-compose exec envoy bash
  4. $ bash send_request.sh

The script above (send_request.sh) sends a continuous stream of HTTP requests to Envoy, which in turn forwards the requests to the backend container.

Fault injection is configured in Envoy but turned off (i.e. affects 0% of requests).

Consequently, you should see a continuous sequence of HTTP 200 response codes.

Step 3: Test Envoy’s abort fault injection

Turn on abort fault injection via the runtime using the commands below.

Terminal 3

  1. $ docker-compose exec envoy bash
  2. $ bash enable_abort_fault_injection.sh

The script above enables HTTP aborts for 100% of requests.

You should now see a continuous sequence of HTTP 503 responses for all requests.

To disable the abort injection:

Terminal 3

  1. $ bash disable_abort_fault_injection.sh

Step 4: Test Envoy’s delay fault injection

Turn on delay fault injection via the runtime using the commands below.

Terminal 3

  1. $ docker-compose exec envoy bash
  2. $ bash enable_delay_fault_injection.sh

The script above will add a 3-second delay to 50% of HTTP requests.

You should now see a continuous sequence of HTTP 200 responses for all requests, but half of the requests will take 3 seconds to complete.

To disable the delay injection:

Terminal 3

  1. $ bash disable_delay_fault_injection.sh

Step 5: Check the current runtime filesystem

To see the current runtime filesystem overview:

Terminal 3

  1. $ tree /srv/runtime

See also

Fault injection

Learn more about Envoy’s HTTP fault injection filter.