-
Notifications
You must be signed in to change notification settings - Fork 619
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding start and stop black hole port fault implementation #4355
Conversation
9fe4569
to
da7e8d8
Compare
cmdOutput, cmdErr := h.stopNetworkBlackHolePort(ctxWithTimeout, aws.StringValue(request.Protocol), port, chainName, | ||
taskMetadata.TaskNetworkConfig.NetworkMode, taskMetadata.TaskNetworkConfig.NetworkNamespaces[0].Path, insertTable) | ||
|
||
if err := ctx.Err(); err == context.DeadlineExceeded { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about err != DeadlineExceeded
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, was hoping to check for context timeout has been reached here. All other errors will still be an internal error but will include the specific error in the error response.
b2326b7
to
e9709f0
Compare
5470641
to
cff31c8
Compare
cff31c8
to
9027b49
Compare
Summary
This PR will introduce both start and stop network black hole port fault injection into the
ecs-agent
directory. It does so by makingiptables
commands viaos/exec
.Implementation details
We will be adding two new functions,
startNetworkBlackholePort()
andstopNetworkBlackHolePort()
, into theecs-agent/tmds/handlers/fault/v1/handlers/handlers.go
file.startNetworkBlackholePort()
: This function is responsible for starting/injecting a new network black hole port with the specified traffic type, protocol, and port number that's passed from the request body. It is called inStartNetworkBlackholePort()
. The general workflow of this function is as followed:iptables -N <chain>
(the chain name is in the form of "--")iptables -A <chain> -p <protocol> --dport <port> -j DROP
stopNetworkBlackHolePort()
: This function is responsible for stopping a specific network black hole port with the specified traffic type, protocol, and port number that's passed from the request body. It is called inStopNetworkBlackHolePort()
. The general workflow of this function is as followed:iptables -F <chain>
iptables -D <INPUT/OUTPUT> -j <chain>
iptables -X <chain>
Similar to
CheckNetworkBlackHolePort()
, bothStartNetworkBlackholePort()
andStopNetworkBlackHolePort()
handler functions will also have the following checks before responding back to the request.:startNetworkBlackholePort()
andstopNetworkBlackHolePort()
takes too long to finish then we will respond back with a 500 + "request timed out" error message.iptables
commands instartNetworkBlackholePort()
andstopNetworkBlackHolePort()
then we will respond back with a 500 + whatever the standard error was from theiptables
commandsTesting
generateStartBlackHolePortFaultTestCases
andgenerateStopBlackHolePortFaultTestCases
with mock exec expectation calls. Existing test cases now also have the correct mock exec expectation calls.generateNetworkBlackHolePortTestCases
togenerateCommonNetworkBlackHolePortTestCases
agent/handlers/task_server_setup_test.go
to just test whether or not we can make successful requests to each of the fault injection TMDS endpoints. The deleted tests are also already tested inecs-agent/tmds/handlers/fault/v1/handlers/handlers_test.go
already.Manual Testing:
Hooked up the fault injection handlers to also register upon TMDS server start up, ran a AWSVPC task that calls all three BHP endpoints (start -> check status -> stop BHP fault)
Corresponding iptables output in task ENI/network namespace
Same test but using Host mode task
Corresponding iptables on host network namespace
New tests cover the changes: yes
Description for the changelog
Feature: Adding start and stop network black hole port fault implementation
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.