Skip to content

Commit

Permalink
Add full task and EBS volume context to EBS debug log messages
Browse files Browse the repository at this point in the history
  • Loading branch information
sparrc committed Sep 11, 2024
1 parent 2cfc68d commit 2df9191
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
10 changes: 8 additions & 2 deletions agent/api/task/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -3473,11 +3473,17 @@ func (task *Task) IsEBSTaskAttachEnabled() bool {
}

func (task *Task) isEBSTaskAttachEnabledUnsafe() bool {
logger.Debug("Checking if there are any ebs volume configs")
taskFields := task.fieldsUnsafe()
logger.Debug("Checking if there are any ebs volume configs", taskFields)
for _, tv := range task.Volumes {
switch tv.Volume.(type) {
case *taskresourcevolume.EBSTaskVolumeConfig:
logger.Debug("found ebs volume config")
logger.Debug("Found ebs volume config", taskFields, logger.Fields{
"volumeName": tv.Volume.GetVolumeName(),
"volumeId": tv.Volume.GetVolumeId(),
"volumeType": tv.Volume.GetType(),
"volumeSource": tv.Volume.Source(),
})
return true
default:
continue
Expand Down
23 changes: 23 additions & 0 deletions agent/stats/engine_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ func (engine *DockerStatsEngine) getEBSVolumeMetrics(taskArn string) []*ecstcs.V
"taskArn": taskArn,
})
return nil
} else {
logger.Debug("Task is EBS-backed, gathering EBS volume metrics.", logger.Fields{
"taskArn": taskArn,
})
}

// TODO: Remove the CSI client from the stats engine and just always have the CSI client created
Expand All @@ -67,9 +71,28 @@ func (engine *DockerStatsEngine) fetchEBSVolumeMetrics(task *apitask.Task, taskA
"VolumeId": volumeId,
"SourceVolumeHostPath": hostPath,
"Error": err,
"taskArn": taskArn,
})
continue
}
if metric.Capacity <= 0 {
logger.Error("Failed to gather metrics for EBS volume. Received invalid EBS volume size.", logger.Fields{
"VolumeId": volumeId,
"SourceVolumeHostPath": hostPath,
"Error": err,
"taskArn": taskArn,
"Utilized": metric.Used,
"Size": metric.Capacity,
})
continue
}
logger.Debug("Gathered metrics for EBS volume", logger.Fields{
"VolumeId": volumeId,
"SourceVolumeHostPath": hostPath,
"taskArn": taskArn,
"Utilized": metric.Used,
"Size": metric.Capacity,
})
usedBytes := aws.Float64((float64)(metric.Used))
totalBytes := aws.Float64((float64)(metric.Capacity))
metrics = append(metrics, &ecstcs.VolumeMetric{
Expand Down

0 comments on commit 2df9191

Please sign in to comment.