Skip to content

Commit 2e7c715

Browse files
committed
Add container name to ECS ListTagsForResource request headers
Enhance CloudTrail visibility by including container name in HTTP User-Agent header when ECS agent makes ListTagsForResource API calls on behalf of containers. Changes: - Add ContainerNameByV3EndpointID method to TaskEngineState interface - Modify NewTaskResponse to accept v3EndpointID and pass container name to context - Update GetResourceTags to accept context parameter for container identification - Enhance ecsRoundTripper.userAgent to append container name from request context - Update TMDS v4 handler to pass endpoint ID through call chain - Add comprehensive unit tests for new functionality This enables tracing HTTP requests from containers to specific ECS API calls in CloudTrail logs, improving observability and debugging capabilities.
1 parent 6e9b8f3 commit 2e7c715

File tree

22 files changed

+439
-100
lines changed

22 files changed

+439
-100
lines changed

agent/engine/dockerstate/docker_task_engine_state.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ type TaskEngineState interface {
8282
DockerIDByV3EndpointID(v3EndpointID string) (string, bool)
8383
// TaskARNByV3EndpointID returns a taskARN for a given v3 endpoint ID
8484
TaskARNByV3EndpointID(v3EndpointID string) (string, bool)
85+
// ContainerNameByV3EndpointID returns the container name for a given TMDS v3 endpoint ID
86+
ContainerNameByV3EndpointID(v3EndpointID string) (string, bool)
8587
// GetAllEBSAttachments returns all of the ebs attachments
8688
GetAllEBSAttachments() []*apiresource.ResourceAttachment
8789
// AllPendingEBSAttachments reutrns all of the ebs attachments that haven't sent a state change
@@ -713,3 +715,22 @@ func (state *DockerTaskEngineState) TaskARNByV3EndpointID(v3EndpointID string) (
713715
taskArn, ok := state.v3EndpointIDToTask[v3EndpointID]
714716
return taskArn, ok
715717
}
718+
719+
// ContainerNameByV3EndpointID returns the container name for a given TMDS v3 endpoint ID
720+
func (state *DockerTaskEngineState) ContainerNameByV3EndpointID(v3EndpointID string) (string, bool) {
721+
state.lock.RLock()
722+
defer state.lock.RUnlock()
723+
724+
dockerContainerID, ok := state.v3EndpointIDToDockerID[v3EndpointID]
725+
if !ok {
726+
return "", false
727+
}
728+
729+
dockerContainer, ok := state.idToContainer[dockerContainerID]
730+
if !ok {
731+
return "", false
732+
}
733+
734+
// Extract the name of the container specified in the ECS task definition
735+
return dockerContainer.Container.Name, true
736+
}

agent/engine/dockerstate/dockerstate_test.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,3 +666,50 @@ func TestRemoveTaskRemoveV3EndpointID(t *testing.T) {
666666
_, ok = state.v3EndpointIDToDockerID["new-uuid-2"]
667667
assert.False(t, ok)
668668
}
669+
670+
// TestContainerNameByV3EndpointID tests that ContainerNameByV3EndpointID returns the correct container name
671+
func TestContainerNameByV3EndpointID(t *testing.T) {
672+
state := newDockerTaskEngineState()
673+
container1 := &apicontainer.Container{
674+
Name: "web-server",
675+
V3EndpointID: "endpoint-uuid-1",
676+
}
677+
dockerContainer1 := &apicontainer.DockerContainer{
678+
DockerID: "docker-id-1",
679+
Container: container1,
680+
}
681+
682+
container2 := &apicontainer.Container{
683+
Name: "sidecar-proxy",
684+
V3EndpointID: "endpoint-uuid-2",
685+
}
686+
dockerContainer2 := &apicontainer.DockerContainer{
687+
DockerID: "docker-id-2",
688+
Container: container2,
689+
}
690+
691+
task := &apitask.Task{
692+
Arn: "task-arn",
693+
Containers: []*apicontainer.Container{
694+
container1,
695+
container2,
696+
},
697+
}
698+
699+
state.AddTask(task)
700+
state.AddContainer(dockerContainer1, task)
701+
state.AddContainer(dockerContainer2, task)
702+
703+
// Test successful lookups
704+
containerName1, found1 := state.ContainerNameByV3EndpointID("endpoint-uuid-1")
705+
assert.True(t, found1)
706+
assert.Equal(t, "web-server", containerName1)
707+
708+
containerName2, found2 := state.ContainerNameByV3EndpointID("endpoint-uuid-2")
709+
assert.True(t, found2)
710+
assert.Equal(t, "sidecar-proxy", containerName2)
711+
712+
// Test lookup with non-existent endpoint ID
713+
_, found3 := state.ContainerNameByV3EndpointID("non-existent-uuid")
714+
assert.False(t, found3)
715+
}

agent/engine/dockerstate/mocks/dockerstate_mocks.go

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

agent/handlers/task_server_setup_test.go

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2514,6 +2514,7 @@ func TestV2TaskMetadataWithTags(t *testing.T) {
25142514
state.EXPECT().GetTaskByIPAddress(remoteIP).Return(taskARN, true),
25152515
state.EXPECT().TaskByArn(taskARN).Return(task, true),
25162516
state.EXPECT().ContainerMapByArn(taskARN).Return(containerNameToDockerContainer, true),
2517+
state.EXPECT().ContainerNameByV3EndpointID("").Return(containerName, true),
25172518
)
25182519
}
25192520

@@ -2529,9 +2530,9 @@ func TestV2TaskMetadataWithTags(t *testing.T) {
25292530
setStateExpectations: happyStateExpectations,
25302531
setECSClientExpectations: func(ecsClient *mock_ecs.MockECSClient) {
25312532
gomock.InOrder(
2532-
ecsClient.EXPECT().GetResourceTags(containerInstanceArn).
2533+
ecsClient.EXPECT().GetResourceTags(gomock.Any(), containerInstanceArn).
25332534
Return(ecsInstanceTags, nil),
2534-
ecsClient.EXPECT().GetResourceTags(taskARN).Return(ecsTaskTags, nil),
2535+
ecsClient.EXPECT().GetResourceTags(gomock.Any(), taskARN).Return(ecsTaskTags, nil),
25352536
)
25362537
},
25372538
expectedStatusCode: http.StatusOK,
@@ -2548,8 +2549,8 @@ func TestV2TaskMetadataWithTags(t *testing.T) {
25482549
setStateExpectations: happyStateExpectations,
25492550
setECSClientExpectations: func(ecsClient *mock_ecs.MockECSClient) {
25502551
gomock.InOrder(
2551-
ecsClient.EXPECT().GetResourceTags(containerInstanceArn).Return(ecsInstanceTags, nil),
2552-
ecsClient.EXPECT().GetResourceTags(taskARN).Return(nil, errors.New("error")),
2552+
ecsClient.EXPECT().GetResourceTags(gomock.Any(), containerInstanceArn).Return(ecsInstanceTags, nil),
2553+
ecsClient.EXPECT().GetResourceTags(gomock.Any(), taskARN).Return(nil, errors.New("error")),
25532554
)
25542555
},
25552556
expectedStatusCode: http.StatusOK,
@@ -2564,8 +2565,8 @@ func TestV2TaskMetadataWithTags(t *testing.T) {
25642565
setStateExpectations: happyStateExpectations,
25652566
setECSClientExpectations: func(ecsClient *mock_ecs.MockECSClient) {
25662567
gomock.InOrder(
2567-
ecsClient.EXPECT().GetResourceTags(containerInstanceArn).Return(nil, errors.New("error")),
2568-
ecsClient.EXPECT().GetResourceTags(taskARN).Return(ecsTaskTags, nil),
2568+
ecsClient.EXPECT().GetResourceTags(gomock.Any(), containerInstanceArn).Return(nil, errors.New("error")),
2569+
ecsClient.EXPECT().GetResourceTags(gomock.Any(), taskARN).Return(ecsTaskTags, nil),
25692570
)
25702571
},
25712572
expectedStatusCode: http.StatusOK,
@@ -2578,8 +2579,8 @@ func TestV2TaskMetadataWithTags(t *testing.T) {
25782579
setStateExpectations: happyStateExpectations,
25792580
setECSClientExpectations: func(ecsClient *mock_ecs.MockECSClient) {
25802581
gomock.InOrder(
2581-
ecsClient.EXPECT().GetResourceTags(containerInstanceArn).Return(nil, errors.New("error")),
2582-
ecsClient.EXPECT().GetResourceTags(taskARN).Return(nil, errors.New("error")),
2582+
ecsClient.EXPECT().GetResourceTags(gomock.Any(), containerInstanceArn).Return(nil, errors.New("error")),
2583+
ecsClient.EXPECT().GetResourceTags(gomock.Any(), taskARN).Return(nil, errors.New("error")),
25832584
)
25842585
},
25852586
expectedStatusCode: http.StatusOK,
@@ -2644,8 +2645,8 @@ func TestV3TaskMetadataWithTags(t *testing.T) {
26442645

26452646
happyECSClientExpectations := func(ecsClient *mock_ecs.MockECSClient) {
26462647
gomock.InOrder(
2647-
ecsClient.EXPECT().GetResourceTags(containerInstanceArn).Return(ecsInstanceTags, nil),
2648-
ecsClient.EXPECT().GetResourceTags(taskARN).Return(ecsTaskTags, nil),
2648+
ecsClient.EXPECT().GetResourceTags(gomock.Any(), containerInstanceArn).Return(ecsInstanceTags, nil),
2649+
ecsClient.EXPECT().GetResourceTags(gomock.Any(), taskARN).Return(ecsTaskTags, nil),
26492650
)
26502651
}
26512652
happyStateExpectations := func(state *mock_dockerstate.MockTaskEngineState) {
@@ -2677,8 +2678,8 @@ func TestV3TaskMetadataWithTags(t *testing.T) {
26772678
setStateExpectations: happyStateExpectations,
26782679
setECSClientExpectations: func(ecsClient *mock_ecs.MockECSClient) {
26792680
gomock.InOrder(
2680-
ecsClient.EXPECT().GetResourceTags(containerInstanceArn).Return(nil, errors.New("error")),
2681-
ecsClient.EXPECT().GetResourceTags(taskARN).Return(ecsTaskTags, nil),
2681+
ecsClient.EXPECT().GetResourceTags(gomock.Any(), containerInstanceArn).Return(nil, errors.New("error")),
2682+
ecsClient.EXPECT().GetResourceTags(gomock.Any(), taskARN).Return(ecsTaskTags, nil),
26822683
)
26832684
},
26842685
expectedStatusCode: http.StatusOK,
@@ -2693,8 +2694,8 @@ func TestV3TaskMetadataWithTags(t *testing.T) {
26932694
setStateExpectations: happyStateExpectations,
26942695
setECSClientExpectations: func(ecsClient *mock_ecs.MockECSClient) {
26952696
gomock.InOrder(
2696-
ecsClient.EXPECT().GetResourceTags(containerInstanceArn).Return(ecsInstanceTags, nil),
2697-
ecsClient.EXPECT().GetResourceTags(taskARN).Return(nil, errors.New("error")),
2697+
ecsClient.EXPECT().GetResourceTags(gomock.Any(), containerInstanceArn).Return(ecsInstanceTags, nil),
2698+
ecsClient.EXPECT().GetResourceTags(gomock.Any(), taskARN).Return(nil, errors.New("error")),
26982699
)
26992700
},
27002701
expectedStatusCode: http.StatusOK,
@@ -2707,8 +2708,8 @@ func TestV3TaskMetadataWithTags(t *testing.T) {
27072708
setStateExpectations: happyStateExpectations,
27082709
setECSClientExpectations: func(ecsClient *mock_ecs.MockECSClient) {
27092710
gomock.InOrder(
2710-
ecsClient.EXPECT().GetResourceTags(containerInstanceArn).Return(nil, errors.New("error")),
2711-
ecsClient.EXPECT().GetResourceTags(taskARN).Return(nil, errors.New("error")),
2711+
ecsClient.EXPECT().GetResourceTags(gomock.Any(), containerInstanceArn).Return(nil, errors.New("error")),
2712+
ecsClient.EXPECT().GetResourceTags(gomock.Any(), taskARN).Return(nil, errors.New("error")),
27122713
)
27132714
},
27142715
expectedStatusCode: http.StatusOK,
@@ -2818,8 +2819,8 @@ func TestV4TaskMetadataWithTags(t *testing.T) {
28182819

28192820
happyECSClientExpectations := func(ecsClient *mock_ecs.MockECSClient) {
28202821
gomock.InOrder(
2821-
ecsClient.EXPECT().GetResourceTags(containerInstanceArn).Return(ecsInstanceTags, nil),
2822-
ecsClient.EXPECT().GetResourceTags(taskARN).Return(ecsTaskTags, nil),
2822+
ecsClient.EXPECT().GetResourceTags(gomock.Any(), containerInstanceArn).Return(ecsInstanceTags, nil),
2823+
ecsClient.EXPECT().GetResourceTags(gomock.Any(), taskARN).Return(ecsTaskTags, nil),
28232824
)
28242825
}
28252826
happyStateExpectations := func(state *mock_dockerstate.MockTaskEngineState) {
@@ -2857,8 +2858,8 @@ func TestV4TaskMetadataWithTags(t *testing.T) {
28572858
setStateExpectations: happyStateExpectations,
28582859
setECSClientExpectations: func(ecsClient *mock_ecs.MockECSClient) {
28592860
gomock.InOrder(
2860-
ecsClient.EXPECT().GetResourceTags(containerInstanceArn).Return(nil, errors.New("error")),
2861-
ecsClient.EXPECT().GetResourceTags(taskARN).Return(ecsTaskTags, nil),
2861+
ecsClient.EXPECT().GetResourceTags(gomock.Any(), containerInstanceArn).Return(nil, errors.New("error")),
2862+
ecsClient.EXPECT().GetResourceTags(gomock.Any(), taskARN).Return(ecsTaskTags, nil),
28622863
)
28632864
},
28642865
expectedStatusCode: http.StatusOK,
@@ -2874,8 +2875,8 @@ func TestV4TaskMetadataWithTags(t *testing.T) {
28742875
setStateExpectations: happyStateExpectations,
28752876
setECSClientExpectations: func(ecsClient *mock_ecs.MockECSClient) {
28762877
gomock.InOrder(
2877-
ecsClient.EXPECT().GetResourceTags(containerInstanceArn).Return(ecsInstanceTags, nil),
2878-
ecsClient.EXPECT().GetResourceTags(taskARN).Return(nil, errors.New("error")),
2878+
ecsClient.EXPECT().GetResourceTags(gomock.Any(), containerInstanceArn).Return(ecsInstanceTags, nil),
2879+
ecsClient.EXPECT().GetResourceTags(gomock.Any(), taskARN).Return(nil, errors.New("error")),
28792880
)
28802881
},
28812882
expectedStatusCode: http.StatusOK,
@@ -2891,8 +2892,8 @@ func TestV4TaskMetadataWithTags(t *testing.T) {
28912892
setStateExpectations: happyStateExpectations,
28922893
setECSClientExpectations: func(ecsClient *mock_ecs.MockECSClient) {
28932894
gomock.InOrder(
2894-
ecsClient.EXPECT().GetResourceTags(containerInstanceArn).Return(nil, errors.New("error")),
2895-
ecsClient.EXPECT().GetResourceTags(taskARN).Return(nil, errors.New("error")),
2895+
ecsClient.EXPECT().GetResourceTags(gomock.Any(), containerInstanceArn).Return(nil, errors.New("error")),
2896+
ecsClient.EXPECT().GetResourceTags(gomock.Any(), taskARN).Return(nil, errors.New("error")),
28962897
)
28972898
},
28982899
expectedStatusCode: http.StatusOK,

agent/handlers/v2/response.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@
1414
package v2
1515

1616
import (
17+
"context"
18+
1719
apicontainer "github.com/aws/amazon-ecs-agent/agent/api/container"
1820
"github.com/aws/amazon-ecs-agent/agent/engine/dockerstate"
1921
v1 "github.com/aws/amazon-ecs-agent/agent/handlers/v1"
2022
apicontainerstatus "github.com/aws/amazon-ecs-agent/ecs-agent/api/container/status"
2123
"github.com/aws/amazon-ecs-agent/ecs-agent/api/ecs"
24+
"github.com/aws/amazon-ecs-agent/ecs-agent/httpclient"
2225
ni "github.com/aws/amazon-ecs-agent/ecs-agent/netlib/model/networkinterface"
2326
tmdsresponse "github.com/aws/amazon-ecs-agent/ecs-agent/tmds/handlers/response"
2427
"github.com/aws/amazon-ecs-agent/ecs-agent/tmds/handlers/utils"
@@ -37,6 +40,7 @@ const minimumCPUUnit = 2
3740

3841
// NewTaskResponse creates a new response object for the task
3942
func NewTaskResponse(
43+
endpointID string,
4044
taskARN string,
4145
state dockerstate.TaskEngineState,
4246
ecsClient ecs.ECSClient,
@@ -99,16 +103,23 @@ func NewTaskResponse(
99103
}
100104

101105
if propagateTags {
102-
propagateTagsToMetadata(ecsClient, containerInstanceArn, taskARN, resp, includeV4Metadata)
106+
propagateTagsToMetadata(endpointID, ecsClient, state, containerInstanceArn, taskARN, resp, includeV4Metadata)
103107
}
104108

105109
return resp, nil
106110
}
107111

108112
// propagateTagsToMetadata retrieves container instance and task tags from ECS
109-
func propagateTagsToMetadata(ecsClient ecs.ECSClient, containerInstanceARN, taskARN string, resp *tmdsv2.TaskResponse, includeV4Metadata bool) {
110-
containerInstanceTags, err := ecsClient.GetResourceTags(containerInstanceARN)
113+
func propagateTagsToMetadata(endpointID string, ecsClient ecs.ECSClient, state dockerstate.TaskEngineState, containerInstanceARN, taskARN string,
114+
resp *tmdsv2.TaskResponse, includeV4Metadata bool) {
115+
// Extract the container name and create a context for CloudTrail visibility
116+
ctx := context.Background()
117+
if containerName, found := state.ContainerNameByV3EndpointID(endpointID); found {
118+
ctx = context.WithValue(ctx, httpclient.ContainerNameKey, containerName)
119+
}
111120

121+
// Get container instance tags from ECS
122+
containerInstanceTags, err := ecsClient.GetResourceTags(ctx, containerInstanceARN)
112123
if err == nil {
113124
resp.ContainerInstanceTags = make(map[string]string)
114125
for _, tag := range containerInstanceTags {
@@ -118,7 +129,8 @@ func propagateTagsToMetadata(ecsClient ecs.ECSClient, containerInstanceARN, task
118129
metadataErrorHandling(resp, err, "ContainerInstanceTags", containerInstanceARN, includeV4Metadata)
119130
}
120131

121-
taskTags, err := ecsClient.GetResourceTags(taskARN)
132+
// Get task tags from ECS
133+
taskTags, err := ecsClient.GetResourceTags(ctx, taskARN)
122134
if err == nil {
123135
resp.TaskTags = make(map[string]string)
124136
for _, tag := range taskTags {

agent/handlers/v2/response_test.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ const (
6060
availabilityZone = "us-west-2b"
6161
containerInstanceArn = "containerInstance-test"
6262
hostIp = "0.0.0.0"
63+
testEndpointID = "test-endpoint-id"
6364
)
6465

6566
func TestTaskResponse(t *testing.T) {
@@ -131,7 +132,7 @@ func TestTaskResponse(t *testing.T) {
131132
state.EXPECT().ContainerMapByArn(taskARN).Return(containerNameToDockerContainer, true),
132133
)
133134

134-
taskResponse, err := NewTaskResponse(taskARN, state, ecsClient, cluster, availabilityZone, containerInstanceArn, false, false)
135+
taskResponse, err := NewTaskResponse(testEndpointID, taskARN, state, ecsClient, cluster, availabilityZone, containerInstanceArn, false, false)
135136
assert.NoError(t, err)
136137
_, err = json.Marshal(taskResponse)
137138
assert.NoError(t, err)
@@ -147,7 +148,7 @@ func TestTaskResponse(t *testing.T) {
147148
state.EXPECT().ContainerMapByArn(taskARN).Return(containerNameToDockerContainer, true),
148149
)
149150
// verify that 'v4' response without log driver or options returns blank fields as well
150-
taskResponse, err = NewTaskResponse(taskARN, state, ecsClient, cluster, availabilityZone, containerInstanceArn, false, true)
151+
taskResponse, err = NewTaskResponse(testEndpointID, taskARN, state, ecsClient, cluster, availabilityZone, containerInstanceArn, false, true)
151152
assert.NoError(t, err)
152153
_, err = json.Marshal(taskResponse)
153154
assert.NoError(t, err)
@@ -230,7 +231,7 @@ func TestTaskResponseWithV4Metadata(t *testing.T) {
230231
state.EXPECT().ContainerMapByArn(taskARN).Return(containerNameToDockerContainer, true),
231232
)
232233

233-
taskResponse, err := NewTaskResponse(taskARN, state, ecsClient, cluster, availabilityZone, containerInstanceArn, false, true)
234+
taskResponse, err := NewTaskResponse(testEndpointID, taskARN, state, ecsClient, cluster, availabilityZone, containerInstanceArn, false, true)
234235
assert.NoError(t, err)
235236
_, err = json.Marshal(taskResponse)
236237
assert.NoError(t, err)
@@ -455,7 +456,8 @@ func TestTaskResponseMarshal(t *testing.T) {
455456
gomock.InOrder(
456457
state.EXPECT().TaskByArn(taskARN).Return(task, true),
457458
state.EXPECT().ContainerMapByArn(taskARN).Return(containerNameToDockerContainer, true),
458-
ecsClient.EXPECT().GetResourceTags(containerInstanceArn).Return([]ecstypes.Tag{
459+
state.EXPECT().ContainerNameByV3EndpointID(testEndpointID).Return(containerName, true),
460+
ecsClient.EXPECT().GetResourceTags(gomock.Any(), containerInstanceArn).Return([]ecstypes.Tag{
459461
{
460462
Key: &contInstTag1Key,
461463
Value: &contInstTag1Val,
@@ -465,7 +467,7 @@ func TestTaskResponseMarshal(t *testing.T) {
465467
Value: &contInstTag2Val,
466468
},
467469
}, nil),
468-
ecsClient.EXPECT().GetResourceTags(taskARN).Return([]ecstypes.Tag{
470+
ecsClient.EXPECT().GetResourceTags(gomock.Any(), taskARN).Return([]ecstypes.Tag{
469471
{
470472
Key: &taskTag1Key,
471473
Value: &taskTag1Val,
@@ -477,7 +479,7 @@ func TestTaskResponseMarshal(t *testing.T) {
477479
}, nil),
478480
)
479481

480-
taskResponse, err := NewTaskResponse(taskARN, state, ecsClient, cluster, availabilityZone, containerInstanceArn, true, false)
482+
taskResponse, err := NewTaskResponse(testEndpointID, taskARN, state, ecsClient, cluster, availabilityZone, containerInstanceArn, true, false)
481483
assert.NoError(t, err)
482484

483485
taskResponseJSON, err := json.Marshal(taskResponse)
@@ -711,11 +713,12 @@ func TestTaskResponseWithV4TagsError(t *testing.T) {
711713
gomock.InOrder(
712714
state.EXPECT().TaskByArn(taskARN).Return(task, true),
713715
state.EXPECT().ContainerMapByArn(taskARN).Return(containerNameToDockerContainer, true),
714-
ecsClient.EXPECT().GetResourceTags(containerInstanceArn).Return(nil, containerTagsErr),
715-
ecsClient.EXPECT().GetResourceTags(taskARN).Return(nil, taskTagsErr),
716+
state.EXPECT().ContainerNameByV3EndpointID(testEndpointID).Return(containerName, true),
717+
ecsClient.EXPECT().GetResourceTags(gomock.Any(), containerInstanceArn).Return(nil, containerTagsErr),
718+
ecsClient.EXPECT().GetResourceTags(gomock.Any(), taskARN).Return(nil, taskTagsErr),
716719
)
717720

718-
taskWithTagsResponse, err := NewTaskResponse(taskARN, state, ecsClient, cluster, availabilityZone, containerInstanceArn, true, true)
721+
taskWithTagsResponse, err := NewTaskResponse(testEndpointID, taskARN, state, ecsClient, cluster, availabilityZone, containerInstanceArn, true, true)
719722
assert.NoError(t, err)
720723
_, err = json.Marshal(taskWithTagsResponse)
721724
assert.NoError(t, err)

agent/handlers/v2/task_container_metadata_handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func WriteContainerMetadataResponse(w http.ResponseWriter, containerID string, s
9191
// WriteTaskMetadataResponse writes the task metadata to response writer.
9292
func WriteTaskMetadataResponse(w http.ResponseWriter, taskARN string, cluster string, state dockerstate.TaskEngineState, ecsClient ecs.ECSClient, az, containerInstanceArn string, propagateTags bool) {
9393
// Generate a response for the task
94-
taskResponse, err := NewTaskResponse(taskARN, state, ecsClient, cluster, az, containerInstanceArn, propagateTags, false)
94+
taskResponse, err := NewTaskResponse("", taskARN, state, ecsClient, cluster, az, containerInstanceArn, propagateTags, false)
9595
if err != nil {
9696
errResponseJSON, err := json.Marshal("Unable to generate metadata for task: '" + taskARN + "'")
9797
if e := utils.WriteResponseIfMarshalError(w, err); e != nil {

0 commit comments

Comments
 (0)