Skip to content

Commit c56cd4e

Browse files
committed
Add networkInterface field to logs
1 parent 9809055 commit c56cd4e

File tree

4 files changed

+114
-84
lines changed

4 files changed

+114
-84
lines changed

agent/vendor/github.com/aws/amazon-ecs-agent/ecs-agent/logger/field/constants.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

agent/vendor/github.com/aws/amazon-ecs-agent/ecs-agent/tmds/handlers/fault/v1/handlers/handlers.go

Lines changed: 56 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ecs-agent/logger/field/constants.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,5 @@ const (
7474
ExecutionStoppedAt = "executionStoppedAt"
7575
Region = "region"
7676
DockerVersion = "dockerVersion"
77+
NetworkInterface = "networkInterface"
7778
)

ecs-agent/tmds/handlers/fault/v1/handlers/handlers.go

Lines changed: 56 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,33 +1360,37 @@ func (h *FaultHandler) startNetworkLatencyFaultForInterface(
13601360
cmdOutput, err := h.runExecCommand(ctx, cmdList)
13611361
if err != nil {
13621362
logger.Error("Command execution failed", logger.Fields{
1363-
field.CommandString: tcAddQdiscRootCommandComposed,
1364-
field.Error: err,
1365-
field.CommandOutput: string(cmdOutput[:]),
1366-
field.TaskARN: taskMetadata.TaskARN,
1363+
field.CommandString: tcAddQdiscRootCommandComposed,
1364+
field.Error: err,
1365+
field.CommandOutput: string(cmdOutput[:]),
1366+
field.TaskARN: taskMetadata.TaskARN,
1367+
field.NetworkInterface: interfaceName,
13671368
})
13681369
return err
13691370
}
13701371
logger.Info("Command execution completed", logger.Fields{
1371-
field.CommandString: tcAddQdiscRootCommandComposed,
1372-
field.CommandOutput: string(cmdOutput[:]),
1372+
field.CommandString: tcAddQdiscRootCommandComposed,
1373+
field.CommandOutput: string(cmdOutput[:]),
1374+
field.NetworkInterface: interfaceName,
13731375
})
13741376
tcAddQdiscLossCommandComposed := nsenterPrefix + fmt.Sprintf(
13751377
tcAddQdiscLatencyCommandString, interfaceName, delayInMs, jitterInMs)
13761378
cmdList = strings.Split(tcAddQdiscLossCommandComposed, " ")
13771379
cmdOutput, err = h.runExecCommand(ctx, cmdList)
13781380
if err != nil {
13791381
logger.Error("Command execution failed", logger.Fields{
1380-
field.CommandString: tcAddQdiscLossCommandComposed,
1381-
field.Error: err,
1382-
field.CommandOutput: string(cmdOutput[:]),
1383-
field.TaskARN: taskMetadata.TaskARN,
1382+
field.CommandString: tcAddQdiscLossCommandComposed,
1383+
field.Error: err,
1384+
field.CommandOutput: string(cmdOutput[:]),
1385+
field.TaskARN: taskMetadata.TaskARN,
1386+
field.NetworkInterface: interfaceName,
13841387
})
13851388
return err
13861389
}
13871390
logger.Info("Command execution completed", logger.Fields{
1388-
field.CommandString: tcAddQdiscLossCommandComposed,
1389-
field.CommandOutput: string(cmdOutput[:]),
1391+
field.CommandString: tcAddQdiscLossCommandComposed,
1392+
field.CommandOutput: string(cmdOutput[:]),
1393+
field.NetworkInterface: interfaceName,
13901394
})
13911395
// After creating the queueing discipline, create filters to associate the IPs in the request with the handle.
13921396
// First redirect the allowlisted ip addresses to band 1:3 where is no network impairments.
@@ -1436,32 +1440,36 @@ func (h *FaultHandler) startNetworkPacketLossFaultForInterface(
14361440
cmdOutput, err := h.runExecCommand(ctx, cmdList)
14371441
if err != nil {
14381442
logger.Error("Command execution failed", logger.Fields{
1439-
field.CommandString: tcAddQdiscRootCommandComposed,
1440-
field.Error: err,
1441-
field.CommandOutput: string(cmdOutput[:]),
1442-
field.TaskARN: taskMetadata.TaskARN,
1443+
field.CommandString: tcAddQdiscRootCommandComposed,
1444+
field.Error: err,
1445+
field.CommandOutput: string(cmdOutput[:]),
1446+
field.TaskARN: taskMetadata.TaskARN,
1447+
field.NetworkInterface: interfaceName,
14431448
})
14441449
return err
14451450
}
14461451
logger.Info("Command execution completed", logger.Fields{
1447-
field.CommandString: tcAddQdiscRootCommandComposed,
1448-
field.CommandOutput: string(cmdOutput[:]),
1452+
field.CommandString: tcAddQdiscRootCommandComposed,
1453+
field.CommandOutput: string(cmdOutput[:]),
1454+
field.NetworkInterface: interfaceName,
14491455
})
14501456
tcAddQdiscLossCommandComposed := nsenterPrefix + fmt.Sprintf(tcAddQdiscLossCommandString, interfaceName, lossPercent)
14511457
cmdList = strings.Split(tcAddQdiscLossCommandComposed, " ")
14521458
cmdOutput, err = h.runExecCommand(ctx, cmdList)
14531459
if err != nil {
14541460
logger.Error("Command execution failed", logger.Fields{
1455-
field.CommandString: tcAddQdiscLossCommandComposed,
1456-
field.Error: err,
1457-
field.CommandOutput: string(cmdOutput[:]),
1458-
field.TaskARN: taskMetadata.TaskARN,
1461+
field.CommandString: tcAddQdiscLossCommandComposed,
1462+
field.Error: err,
1463+
field.CommandOutput: string(cmdOutput[:]),
1464+
field.TaskARN: taskMetadata.TaskARN,
1465+
field.NetworkInterface: interfaceName,
14591466
})
14601467
return err
14611468
}
14621469
logger.Info("Command execution completed", logger.Fields{
1463-
field.CommandString: tcAddQdiscLossCommandComposed,
1464-
field.CommandOutput: string(cmdOutput[:]),
1470+
field.CommandString: tcAddQdiscLossCommandComposed,
1471+
field.CommandOutput: string(cmdOutput[:]),
1472+
field.NetworkInterface: interfaceName,
14651473
})
14661474
// After creating the queueing discipline, create filters to associate the IPs in the request with the handle.
14671475
// First redirect the allowlisted ip addresses to band 1:3 where is no network impairments.
@@ -1509,32 +1517,36 @@ func (h *FaultHandler) stopTCFaultForInterface(
15091517
cmdOutput, err := h.runExecCommand(ctx, cmdList)
15101518
if err != nil {
15111519
logger.Error("Command execution failed", logger.Fields{
1512-
field.CommandString: tcDeleteQdiscParentCommandComposed,
1513-
field.Error: err,
1514-
field.CommandOutput: string(cmdOutput[:]),
1515-
field.TaskARN: taskMetadata.TaskARN,
1520+
field.CommandString: tcDeleteQdiscParentCommandComposed,
1521+
field.Error: err,
1522+
field.CommandOutput: string(cmdOutput[:]),
1523+
field.TaskARN: taskMetadata.TaskARN,
1524+
field.NetworkInterface: interfaceName,
15161525
})
15171526
return err
15181527
}
15191528
logger.Info("Command execution completed", logger.Fields{
1520-
field.CommandString: tcDeleteQdiscParentCommandComposed,
1521-
field.CommandOutput: string(cmdOutput[:]),
1529+
field.CommandString: tcDeleteQdiscParentCommandComposed,
1530+
field.CommandOutput: string(cmdOutput[:]),
1531+
field.NetworkInterface: interfaceName,
15221532
})
15231533
tcDeleteQdiscRootCommandComposed := nsenterPrefix + fmt.Sprintf(tcDeleteQdiscRootCommandString, interfaceName)
15241534
cmdList = strings.Split(tcDeleteQdiscRootCommandComposed, " ")
15251535
_, err = h.runExecCommand(ctx, cmdList)
15261536
if err != nil {
15271537
logger.Error("Command execution failed", logger.Fields{
1528-
field.CommandString: tcDeleteQdiscRootCommandComposed,
1529-
field.Error: err,
1530-
field.CommandOutput: string(cmdOutput[:]),
1531-
field.TaskARN: taskMetadata.TaskARN,
1538+
field.CommandString: tcDeleteQdiscRootCommandComposed,
1539+
field.Error: err,
1540+
field.CommandOutput: string(cmdOutput[:]),
1541+
field.TaskARN: taskMetadata.TaskARN,
1542+
field.NetworkInterface: interfaceName,
15321543
})
15331544
return err
15341545
}
15351546
logger.Info("Command execution completed", logger.Fields{
1536-
field.CommandString: tcDeleteQdiscRootCommandComposed,
1537-
field.CommandOutput: string(cmdOutput[:]),
1547+
field.CommandString: tcDeleteQdiscRootCommandComposed,
1548+
field.CommandOutput: string(cmdOutput[:]),
1549+
field.NetworkInterface: interfaceName,
15381550
})
15391551

15401552
return nil
@@ -1581,18 +1593,20 @@ func (h *FaultHandler) checkTCFaultForInterface(
15811593
cmdOutput, err := h.runExecCommand(ctx, cmdList)
15821594
if err != nil {
15831595
logger.Error("Command execution failed", logger.Fields{
1584-
field.CommandString: tcCheckInjectionCommandComposed,
1585-
field.Error: err,
1586-
field.CommandOutput: string(cmdOutput[:]),
1587-
field.TaskARN: taskMetadata.TaskARN,
1596+
field.CommandString: tcCheckInjectionCommandComposed,
1597+
field.Error: err,
1598+
field.CommandOutput: string(cmdOutput[:]),
1599+
field.TaskARN: taskMetadata.TaskARN,
1600+
field.NetworkInterface: interfaceName,
15881601
})
15891602
return false, false, fmt.Errorf("failed to check existing network fault: '%s' command failed with the following error: '%s'. std output: '%s'. TaskArn: %s",
15901603
tcCheckInjectionCommandComposed, err, string(cmdOutput[:]), taskMetadata.TaskARN)
15911604
}
15921605
// Log the command output to better help us debug.
15931606
logger.Info("Command execution completed", logger.Fields{
1594-
field.CommandString: tcCheckInjectionCommandComposed,
1595-
field.CommandOutput: string(cmdOutput[:]),
1607+
field.CommandString: tcCheckInjectionCommandComposed,
1608+
field.CommandOutput: string(cmdOutput[:]),
1609+
field.NetworkInterface: interfaceName,
15961610
})
15971611

15981612
// Check whether latency fault exists and whether packet loss fault exists separately.

0 commit comments

Comments
 (0)