aws / amazon-ecs-agent

Amazon Elastic Container Service Agent
http://aws.amazon.com/ecs/
Apache License 2.0
2.08k stars 616 forks source link

Remove request payload from latency/packet loss stop/status api #4378

Closed tshan2001 closed 1 month ago

tshan2001 commented 2 months ago

Summary

Remove request payload from latency/packet loss stop/status api. When curling the network latency/packet loss stop/status endpoints, request payload is no longer required. Simply doing curl -X POST ${ECS_AGENT_URI}/fault/v1/network-packet-loss/stop will be enough.

Implementation details

Testing

All existing unit/integ tests passed. Modified the test cases order such that

  1. The tests that checks whether the request payload is valid will only be ran for start latency/packet loss endpoints
  2. For test cases for the stop/status endpoints, modified them to include various possible combinations of request payload, including: a. Empty payload b. Happy payload c. Invalid payload All 3 cases should pass since we simply ignore the payload when processing these requests.
  3. Manual testing:
    
    # Inject a packet loss fault
    % curl -X POST \
    ${ECS_AGENT_URI}/fault/v1/network-packet-loss/start \
    --data '{"lossPercent":50, "Sources":["3.5.76.1", "3.5.76.4"], "SourcesToFilter": ["3.5.76.1"]}'
    {"Status":"running"}

Check packet loss

% curl -X POST ${ECS_AGENT_URI}/fault/v1/network-packet-loss/status {"Status":"running"}

Check packet loss with random data (should still work)

% curl -X POST ${ECS_AGENT_URI}/fault/v1/network-packet-loss/status --data '{"lossPercent":50, "Sources":["3.5.76.1", "3.5.76.4"], "SourcesToFilter": ["3.5.76.1"]abcabcabc}' {"Status":"running"}

Stop the fault

% curl -X POST ${ECS_AGENT_URI}/fault/v1/network-packet-loss/stop {"Status":"stopped"}

Now check the fault again (should be not running)

% curl -X POST ${ECS_AGENT_URI}/fault/v1/network-packet-loss/status {"Status":"not-running"}



### Description for the changelog
Remove request payload from latency/packet loss stop/status api.

### Licensing

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.