in agent/handlers/task_server_setup.go [198:325]
func registerFaultHandlers(
muxRouter *mux.Router,
agentState *v4.TMDSAgentState,
metricsFactory metrics.EntryFactory,
execWrapper execwrapper.Exec,
) {
handler := fault.New(agentState, metricsFactory, execWrapper)
if muxRouter == nil {
return
}
// Setting up handler endpoints for network blackhole port fault injections
muxRouter.Handle(
fault.NetworkFaultPath(faulttype.BlackHolePortFaultType, faulttype.StartNetworkFaultPostfix),
fault.TelemetryMiddleware(
tollbooth.LimitFuncHandler(
createRateLimiter(),
handler.StartNetworkBlackholePort(),
),
metricsFactory,
faulttype.StartNetworkFaultPostfix,
faulttype.BlackHolePortFaultType,
),
).Methods("POST")
muxRouter.Handle(
fault.NetworkFaultPath(faulttype.BlackHolePortFaultType, faulttype.StopNetworkFaultPostfix),
fault.TelemetryMiddleware(
tollbooth.LimitFuncHandler(
createRateLimiter(),
handler.StopNetworkBlackHolePort(),
),
metricsFactory,
faulttype.StopNetworkFaultPostfix,
faulttype.BlackHolePortFaultType,
),
).Methods("POST")
muxRouter.Handle(
fault.NetworkFaultPath(faulttype.BlackHolePortFaultType, faulttype.CheckNetworkFaultPostfix),
fault.TelemetryMiddleware(
tollbooth.LimitFuncHandler(
createRateLimiter(),
handler.CheckNetworkBlackHolePort(),
),
metricsFactory,
faulttype.CheckNetworkFaultPostfix,
faulttype.BlackHolePortFaultType,
),
).Methods("POST")
// Setting up handler endpoints for network latency fault injections
muxRouter.Handle(
fault.NetworkFaultPath(faulttype.LatencyFaultType, faulttype.StartNetworkFaultPostfix),
fault.TelemetryMiddleware(
tollbooth.LimitFuncHandler(
createRateLimiter(),
handler.StartNetworkLatency(),
),
metricsFactory,
faulttype.StartNetworkFaultPostfix,
faulttype.LatencyFaultType,
),
).Methods("POST")
muxRouter.Handle(
fault.NetworkFaultPath(faulttype.LatencyFaultType, faulttype.StopNetworkFaultPostfix),
fault.TelemetryMiddleware(
tollbooth.LimitFuncHandler(
createRateLimiter(),
handler.StopNetworkLatency(),
),
metricsFactory,
faulttype.StopNetworkFaultPostfix,
faulttype.LatencyFaultType,
),
).Methods("POST")
muxRouter.Handle(
fault.NetworkFaultPath(faulttype.LatencyFaultType, faulttype.CheckNetworkFaultPostfix),
fault.TelemetryMiddleware(
tollbooth.LimitFuncHandler(
createRateLimiter(),
handler.CheckNetworkLatency(),
),
metricsFactory,
faulttype.CheckNetworkFaultPostfix,
faulttype.LatencyFaultType,
),
).Methods("POST")
// Setting up handler endpoints for network packet loss fault injections
muxRouter.Handle(
fault.NetworkFaultPath(faulttype.PacketLossFaultType, faulttype.StartNetworkFaultPostfix),
fault.TelemetryMiddleware(
tollbooth.LimitFuncHandler(
createRateLimiter(),
handler.StartNetworkPacketLoss(),
),
metricsFactory,
faulttype.StartNetworkFaultPostfix,
faulttype.PacketLossFaultType,
),
).Methods("POST")
muxRouter.Handle(
fault.NetworkFaultPath(faulttype.PacketLossFaultType, faulttype.StopNetworkFaultPostfix),
fault.TelemetryMiddleware(
tollbooth.LimitFuncHandler(
createRateLimiter(),
handler.StopNetworkPacketLoss(),
),
metricsFactory,
faulttype.StopNetworkFaultPostfix,
faulttype.PacketLossFaultType,
),
).Methods("POST")
muxRouter.Handle(
fault.NetworkFaultPath(faulttype.PacketLossFaultType, faulttype.CheckNetworkFaultPostfix),
fault.TelemetryMiddleware(
tollbooth.LimitFuncHandler(
createRateLimiter(),
handler.CheckNetworkPacketLoss(),
),
metricsFactory,
faulttype.CheckNetworkFaultPostfix,
faulttype.PacketLossFaultType,
),
).Methods("POST")
seelog.Debug("Successfully set up Fault TMDS handlers")
}