Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add additional logging for BHP fault
Browse files Browse the repository at this point in the history
Harish Senthilkumar committed Oct 11, 2024
1 parent 087b617 commit 78c2daa
Showing 2 changed files with 68 additions and 4 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 34 additions & 2 deletions ecs-agent/tmds/handlers/fault/v1/handlers/handlers.go
Original file line number Diff line number Diff line change
@@ -189,7 +189,7 @@ func (h *FaultHandler) startNetworkBlackholePort(ctx context.Context, protocol,
return cmdOutput, err
}
if !running {
logger.Info("[INFO] Attempting to start network black hole port fault", logger.Fields{
logger.Info("Attempting to start network black hole port fault", logger.Fields{
"netns": netNs,
"chain": chain,
"taskArn": taskArn,
@@ -214,6 +214,11 @@ func (h *FaultHandler) startNetworkBlackholePort(ctx context.Context, protocol,
})
return string(cmdOutput), err
}
logger.Info("Successfully created new chain", logger.Fields{
"command": newChainCmdString,
"output": string(cmdOutput),
"taskArn": taskArn,
})

// Appending a new rule based on the protocol and port number from the request body
appendRuleCmdString := nsenterPrefix + fmt.Sprintf(iptablesAppendChainRuleCmd, requestTimeoutSeconds, chain, protocol, port)
@@ -228,6 +233,11 @@ func (h *FaultHandler) startNetworkBlackholePort(ctx context.Context, protocol,
})
return string(cmdOutput), err
}
logger.Info("Successfully appended new rule to iptable chain", logger.Fields{
"command": appendRuleCmdString,
"output": string(cmdOutput),
"taskArn": taskArn,
})

// Inserting the chain into the built-in INPUT/OUTPUT table
insertChainCmdString := nsenterPrefix + fmt.Sprintf(iptablesInsertChainCmd, requestTimeoutSeconds, insertTable, chain)
@@ -243,6 +253,12 @@ func (h *FaultHandler) startNetworkBlackholePort(ctx context.Context, protocol,
})
return string(cmdOutput), err
}
logger.Info("Successfully inserted chain into built-in iptable", logger.Fields{
"insertTable": insertTable,
"taskArn": taskArn,
"command": insertChainCmdString,
"output": string(cmdOutput),
})
}
return "", nil
}
@@ -336,7 +352,7 @@ func (h *FaultHandler) stopNetworkBlackHolePort(ctx context.Context, protocol, p
return cmdOutput, err
}
if running {
logger.Info("[INFO] Attempting to stop network black hole port fault", logger.Fields{
logger.Info("Attempting to stop network black hole port fault", logger.Fields{
"netns": netNs,
"chain": chain,
"taskArn": taskArn,
@@ -361,6 +377,11 @@ func (h *FaultHandler) stopNetworkBlackHolePort(ctx context.Context, protocol, p
})
return string(cmdOutput), err
}
logger.Info("Successfully cleared iptable chain", logger.Fields{
"command": clearChainCmdString,
"output": string(cmdOutput),
"taskArn": taskArn,
})

// Removing the chain from either the built-in INPUT/OUTPUT table
deleteFromTableCmdString := nsenterPrefix + fmt.Sprintf(iptablesDeleteFromTableCmd, requestTimeoutSeconds, insertTable, chain)
@@ -376,6 +397,12 @@ func (h *FaultHandler) stopNetworkBlackHolePort(ctx context.Context, protocol, p
})
return string(cmdOutput), err
}
logger.Info("Successfully deleted chain from table", logger.Fields{
"command": deleteFromTableCmdString,
"output": string(cmdOutput),
"insertTable": insertTable,
"taskArn": taskArn,
})

// Deleting the chain
deleteChainCmdString := nsenterPrefix + fmt.Sprintf(iptablesDeleteChainCmd, requestTimeoutSeconds, chain)
@@ -391,6 +418,11 @@ func (h *FaultHandler) stopNetworkBlackHolePort(ctx context.Context, protocol, p
})
return string(cmdOutput), err
}
logger.Info("Successfully deleted chain", logger.Fields{
"command": deleteChainCmdString,
"output": string(cmdOutput),
"taskArn": taskArn,
})
}
return "", nil
}

0 comments on commit 78c2daa

Please sign in to comment.