Skip to content

Commit b2acb97

Browse files
committed
fix(ecsobserver): Fix missing task tags retrieval
1 parent 8279e5b commit b2acb97

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

extension/observer/ecsobserver/fetcher.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ func (f *taskFetcher) getDiscoverableTasks(ctx context.Context) ([]*ecs.Task, er
168168
descRes, err := svc.DescribeTasksWithContext(ctx, &ecs.DescribeTasksInput{
169169
Cluster: cluster,
170170
Tasks: listRes.TaskArns,
171+
Include: []*string{
172+
aws.String("TAGS"),
173+
},
171174
})
172175
if err != nil {
173176
return nil, fmt.Errorf("ecs.DescribeTasks failed: %w", err)

extension/observer/ecsobserver/internal/ecsmock/service_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ func TestCluster_DescribeTasksWithContext(t *testing.T) {
6464
count := 10
6565
c.SetTasks(GenTasks("p", count, func(_ int, task *ecs.Task) {
6666
task.LastStatus = aws.String("running")
67+
task.Tags = []*ecs.Tag{
68+
{
69+
Key: aws.String("Name"),
70+
Value: aws.String("TestDescribeTaskWithTags"),
71+
},
72+
}
6773
}))
6874

6975
t.Run("invalid cluster", func(t *testing.T) {
@@ -88,6 +94,14 @@ func TestCluster_DescribeTasksWithContext(t *testing.T) {
8894
assert.Len(t, res.Tasks, 1)
8995
assert.Len(t, res.Failures, 1)
9096
})
97+
98+
t.Run("tags not found", func(t *testing.T) {
99+
req := &ecs.DescribeTasksInput{Include: []*string{aws.String("TAGS")}, Tasks: []*string{aws.String("p0"), aws.String(fmt.Sprintf("p%d", count))}}
100+
res, err := c.DescribeTasksWithContext(ctx, req)
101+
require.NoError(t, err)
102+
assert.Equal(t, res.Tasks[0].Tags[0].Key, aws.String("Name"))
103+
assert.Equal(t, res.Tasks[0].Tags[0].Value, aws.String("TestDescribeTaskWithTags"))
104+
})
91105
}
92106

93107
func TestCluster_DescribeTaskDefinitionWithContext(t *testing.T) {

0 commit comments

Comments
 (0)