diff --git a/agent/api/task/task.go b/agent/api/task/task.go index d7432f72a03..821bee76124 100644 --- a/agent/api/task/task.go +++ b/agent/api/task/task.go @@ -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 diff --git a/agent/stats/engine_unix.go b/agent/stats/engine_unix.go index 8d6cff2771f..43e9d047818 100644 --- a/agent/stats/engine_unix.go +++ b/agent/stats/engine_unix.go @@ -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 @@ -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{