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 9ddccf9 commit 529b9b6
Show file tree
Hide file tree
Showing 2 changed files with 30 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 @@ -3482,11 +3482,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
22 changes: 22 additions & 0 deletions agent/stats/engine_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ func (engine *DockerStatsEngine) getEBSVolumeMetrics(taskArn string) []*ecstcs.V
})
return nil
}
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
// since a new connection is created regardless and it'll make the stats engine less stateful
Expand All @@ -67,9 +70,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 529b9b6

Please sign in to comment.