@@ -37,8 +37,8 @@ import (
3737 "github.com/aws/amazon-ecs-agent/ecs-agent/tmds/utils/netconfig"
3838 "github.com/aws/amazon-ecs-agent/ecs-agent/utils/execwrapper"
3939
40+ "github.com/aws/aws-sdk-go-v2/aws"
4041 ecstypes "github.com/aws/aws-sdk-go-v2/service/ecs/types"
41- "github.com/aws/aws-sdk-go/aws"
4242 "github.com/gorilla/mux"
4343)
4444
@@ -127,8 +127,8 @@ func (h *FaultHandler) StartNetworkBlackholePort() func(http.ResponseWriter, *ht
127127 return
128128 }
129129
130- if aws .StringValue (request .TrafficType ) == types .TrafficTypeEgress &&
131- aws .Uint16Value (request .Port ) == tmds .PortForTasks {
130+ if aws .ToString (request .TrafficType ) == types .TrafficTypeEgress &&
131+ aws .ToUint16 (request .Port ) == tmds .PortForTasks {
132132 // Add TMDS IP to SouresToFilter so that access to TMDS is not blocked for the task
133133 request .AddSourceToFilterIfNotAlready (tmds .IPForTasks )
134134 }
@@ -154,15 +154,15 @@ func (h *FaultHandler) StartNetworkBlackholePort() func(http.ResponseWriter, *ht
154154 networkMode := ecstypes .NetworkMode (taskMetadata .TaskNetworkConfig .NetworkMode )
155155 taskArn := taskMetadata .TaskARN
156156 stringToBeLogged := "Failed to start fault"
157- port := strconv .FormatUint (uint64 (aws .Uint16Value (request .Port )), 10 )
158- chainName := fmt .Sprintf ("%s-%s-%s" , aws .StringValue (request .TrafficType ), aws .StringValue (request .Protocol ), port )
157+ port := strconv .FormatUint (uint64 (aws .ToUint16 (request .Port )), 10 )
158+ chainName := fmt .Sprintf ("%s-%s-%s" , aws .ToString (request .TrafficType ), aws .ToString (request .Protocol ), port )
159159 insertTable := "INPUT"
160- if aws .StringValue (request .TrafficType ) == "egress" {
160+ if aws .ToString (request .TrafficType ) == "egress" {
161161 insertTable = "OUTPUT"
162162 }
163163
164- _ , cmdErr := h .startNetworkBlackholePort (ctxWithTimeout , aws .StringValue (request .Protocol ),
165- port , aws .StringValueSlice (request .SourcesToFilter ), chainName ,
164+ _ , cmdErr := h .startNetworkBlackholePort (ctxWithTimeout , aws .ToString (request .Protocol ),
165+ port , aws .ToStringSlice (request .SourcesToFilter ), chainName ,
166166 networkMode , networkNSPath , insertTable , taskArn )
167167 if err := ctxWithTimeout .Err (); errors .Is (err , context .DeadlineExceeded ) {
168168 statusCode = http .StatusInternalServerError
@@ -339,14 +339,14 @@ func (h *FaultHandler) StopNetworkBlackHolePort() func(http.ResponseWriter, *htt
339339 networkMode := ecstypes .NetworkMode (taskMetadata .TaskNetworkConfig .NetworkMode )
340340 taskArn := taskMetadata .TaskARN
341341 stringToBeLogged := "Failed to stop fault"
342- port := strconv .FormatUint (uint64 (aws .Uint16Value (request .Port )), 10 )
343- chainName := fmt .Sprintf ("%s-%s-%s" , aws .StringValue (request .TrafficType ), aws .StringValue (request .Protocol ), port )
342+ port := strconv .FormatUint (uint64 (aws .ToUint16 (request .Port )), 10 )
343+ chainName := fmt .Sprintf ("%s-%s-%s" , aws .ToString (request .TrafficType ), aws .ToString (request .Protocol ), port )
344344 insertTable := "INPUT"
345- if aws .StringValue (request .TrafficType ) == "egress" {
345+ if aws .ToString (request .TrafficType ) == "egress" {
346346 insertTable = "OUTPUT"
347347 }
348348
349- _ , cmdErr := h .stopNetworkBlackHolePort (ctxWithTimeout , aws .StringValue (request .Protocol ), port , chainName ,
349+ _ , cmdErr := h .stopNetworkBlackHolePort (ctxWithTimeout , aws .ToString (request .Protocol ), port , chainName ,
350350 networkMode , networkNSPath , insertTable , taskArn )
351351
352352 if err := ctxWithTimeout .Err (); errors .Is (err , context .DeadlineExceeded ) {
@@ -505,9 +505,9 @@ func (h *FaultHandler) CheckNetworkBlackHolePort() func(http.ResponseWriter, *ht
505505 networkMode := ecstypes .NetworkMode (taskMetadata .TaskNetworkConfig .NetworkMode )
506506 taskArn := taskMetadata .TaskARN
507507 stringToBeLogged := "Failed to check fault"
508- port := strconv .FormatUint (uint64 (aws .Uint16Value (request .Port )), 10 )
509- chainName := fmt .Sprintf ("%s-%s-%s" , aws .StringValue (request .TrafficType ), aws .StringValue (request .Protocol ), port )
510- running , _ , cmdErr := h .checkNetworkBlackHolePort (ctxWithTimeout , aws .StringValue (request .Protocol ), port , chainName ,
508+ port := strconv .FormatUint (uint64 (aws .ToUint16 (request .Port )), 10 )
509+ chainName := fmt .Sprintf ("%s-%s-%s" , aws .ToString (request .TrafficType ), aws .ToString (request .Protocol ), port )
510+ running , _ , cmdErr := h .checkNetworkBlackHolePort (ctxWithTimeout , aws .ToString (request .Protocol ), port , chainName ,
511511 networkMode , networkNSPath , taskArn )
512512
513513 // We've timed out trying to check if the black hole port fault injection is running
@@ -1243,8 +1243,8 @@ func (h *FaultHandler) startNetworkLatencyFault(ctx context.Context, taskMetadat
12431243 if networkMode == ecstypes .NetworkModeAwsvpc {
12441244 nsenterPrefix = fmt .Sprintf (nsenterCommandString , taskMetadata .TaskNetworkConfig .NetworkNamespaces [0 ].Path )
12451245 }
1246- delayInMs := aws .Uint64Value (request .DelayMilliseconds )
1247- jitterInMs := aws .Uint64Value (request .JitterMilliseconds )
1246+ delayInMs := aws .ToUint64 (request .DelayMilliseconds )
1247+ jitterInMs := aws .ToUint64 (request .JitterMilliseconds )
12481248
12491249 // Command to be executed:
12501250 // <nsenterPrefix> tc qdisc add dev <interfaceName> root handle 1: prio priomap 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
@@ -1304,7 +1304,7 @@ func (h *FaultHandler) startNetworkPacketLossFault(ctx context.Context, taskMeta
13041304 if networkMode == ecstypes .NetworkModeAwsvpc {
13051305 nsenterPrefix = fmt .Sprintf (nsenterCommandString , taskMetadata .TaskNetworkConfig .NetworkNamespaces [0 ].Path )
13061306 }
1307- lossPercent := aws .Uint64Value (request .LossPercent )
1307+ lossPercent := aws .ToUint64 (request .LossPercent )
13081308
13091309 // Command to be executed:
13101310 // <nsenterPrefix> tc qdisc add dev <interfaceName> root handle 1: prio priomap 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
@@ -1491,7 +1491,7 @@ func (h *FaultHandler) addIPAddressesToFilter(
14911491 ctx context.Context , ipAddressList []* string , taskMetadata * state.TaskResponse ,
14921492 nsenterPrefix , commandString , interfaceName string ) error {
14931493 for _ , ip := range ipAddressList {
1494- commandComposed := nsenterPrefix + fmt .Sprintf (commandString , interfaceName , aws .StringValue (ip ))
1494+ commandComposed := nsenterPrefix + fmt .Sprintf (commandString , interfaceName , aws .ToString (ip ))
14951495 cmdList := strings .Split (commandComposed , " " )
14961496 cmdOutput , err := h .runExecCommand (ctx , cmdList )
14971497 if err != nil {
0 commit comments