This PR adds a tollbooth ratelimiter to the Fault Injection handlers, enforcing a request limit to control how frequently fault injection operations can be triggered.
Implementation details
createRateLimiter is used to create a new tollbooth rate limiter with rate limit of 0.2 ( 1 request per 5 seconds).
The rate limiter is then applied to network fault injection endpoints such as blackhole port faults, latency faults and packet loss faults.
Testing
Agent with these changes was built and a standard task was launched using the agent with rate limiter.
Accessed the task container and called the Fault Injection APIs back to back
# curl -X GET $ECS_AGENT_URI/fault/v1/network-blackhole-port -d '{"Port":123}' -v
Trying 169.254.170.2:80...
Connected to 169.254.170.2 (169.254.170.2) port 80 (#0)
Summary
This PR adds a tollbooth ratelimiter to the Fault Injection handlers, enforcing a request limit to control how frequently fault injection operations can be triggered.
Implementation details
createRateLimiter
is used to create a new tollbooth rate limiter with rate limit of 0.2 ( 1 request per 5 seconds).Testing
curl -X GET $ECS_AGENT_URI/fault/v1/network-blackhole-port -d '{"Port":123}' -v
429 error
.TestRateLimiterIntegration
integration test has been added as well to ensure the rate limiter works as expected.New tests cover the changes: yes
Description for the changelog
Add ratelimiter for fault injection handlers
Additional Information
Does this PR include breaking model changes? If so, Have you added transformation functions?
**Does this PR include the addition of new environment variables in the README?**Licensing
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.