From 41b52a310ea72082fee4d51551ba0f49ad678ff0 Mon Sep 17 00:00:00 2001 From: Sharanya Devaraj Date: Mon, 20 Aug 2018 17:01:07 +0000 Subject: [PATCH 1/5] handlers: Add Volumes to v1 and v2 metadata --- agent/api/container/container.go | 19 ++++ agent/engine/docker_task_engine.go | 8 +- agent/handlers/v1/response.go | 28 ++++++ agent/handlers/v1/response_test.go | 155 +++++++++++++++++++---------- agent/handlers/v2/response.go | 2 + agent/handlers/v2/response_test.go | 18 ++++ 6 files changed, 178 insertions(+), 52 deletions(-) diff --git a/agent/api/container/container.go b/agent/api/container/container.go index 9eb63f490d4..f576ed8925e 100644 --- a/agent/api/container/container.go +++ b/agent/api/container/container.go @@ -190,6 +190,9 @@ type Container struct { // KnownPortBindingsUnsafe is an array of port bindings for the container. KnownPortBindingsUnsafe []PortBinding `json:"KnownPortBindings"` + // VolumesUnsafe is an array of volume mounts in the container. + VolumesUnsafe []docker.Mount + // SteadyStateStatusUnsafe specifies the steady state status for the container // If uninitialized, it's assumed to be set to 'ContainerRunning'. Even though // it's not only supposed to be set when the container is being created, it's @@ -535,6 +538,22 @@ func (c *Container) GetKnownPortBindings() []PortBinding { return c.KnownPortBindingsUnsafe } +// SetVolumes sets the volumes mounted in a container +func (c *Container) SetVolumes(volumes []docker.Mount) { + c.lock.Lock() + defer c.lock.Unlock() + + c.VolumesUnsafe = volumes +} + +// GetVolumes returns the volumes mounted in a container +func (c *Container) GetVolumes() []docker.Mount { + c.lock.RLock() + defer c.lock.RUnlock() + + return c.VolumesUnsafe +} + // HealthStatusShouldBeReported returns true if the health check is defined in // the task definition func (c *Container) HealthStatusShouldBeReported() bool { diff --git a/agent/engine/docker_task_engine.go b/agent/engine/docker_task_engine.go index c23d4199f59..97218e2c32d 100644 --- a/agent/engine/docker_task_engine.go +++ b/agent/engine/docker_task_engine.go @@ -337,8 +337,12 @@ func updateContainerMetadata(metadata *dockerapi.DockerContainerMetadata, contai } // Update volume for empty volume container - if metadata.Volumes != nil && container.IsInternal() { - task.UpdateMountPoints(container, metadata.Volumes) + if metadata.Volumes != nil { + if container.IsInternal() { + task.UpdateMountPoints(container, metadata.Volumes) + } else { + container.SetVolumes(metadata.Volumes) + } } // Set Exitcode if it's not set diff --git a/agent/handlers/v1/response.go b/agent/handlers/v1/response.go index 591200341c4..05da93d586d 100644 --- a/agent/handlers/v1/response.go +++ b/agent/handlers/v1/response.go @@ -51,6 +51,14 @@ type ContainerResponse struct { Name string `json:"Name"` Ports []PortResponse `json:"Ports,omitempty"` Networks []containermetadata.Network `json:"Networks,omitempty"` + Volumes []VolumeResponse `json:"Volumes,omitempty"` +} + +// VolumeResponse is the schema for the volume response JSON object +type VolumeResponse struct { + DockerName string `json:"DockerName,omitempty"` + Source string `json:"Source,omitempty"` + Destination string `json:"Destination,omitempty"` } // PortResponse defines the schema for portmapping response JSON @@ -101,6 +109,7 @@ func NewContainerResponse(dockerContainer *apicontainer.DockerContainer, eni *ap } resp.Ports = NewPortBindingsResponse(dockerContainer, eni) + resp.Volumes = NewVolumesResponse(dockerContainer) if eni != nil { resp.Networks = []containermetadata.Network{ @@ -144,6 +153,25 @@ func NewPortBindingsResponse(dockerContainer *apicontainer.DockerContainer, eni return resp } +// NewVolumesResponse creates VolumeResponse for a container +func NewVolumesResponse(dockerContainer *apicontainer.DockerContainer) []VolumeResponse { + container := dockerContainer.Container + resp := []VolumeResponse{} + + volumes := container.GetVolumes() + + for _, volume := range volumes { + volResp := VolumeResponse{ + DockerName: volume.Name, + Source: volume.Source, + Destination: volume.Destination, + } + + resp = append(resp, volResp) + } + return resp +} + // NewTasksResponse creates TasksResponse for all the tasks. func NewTasksResponse(state dockerstate.TaskEngineState) *TasksResponse { allTasks := state.AllTasks() diff --git a/agent/handlers/v1/response_test.go b/agent/handlers/v1/response_test.go index db664c2332e..07beab1c86c 100644 --- a/agent/handlers/v1/response_test.go +++ b/agent/handlers/v1/response_test.go @@ -16,11 +16,12 @@ package v1 import ( "encoding/json" "testing" - + apicontainer "github.com/aws/amazon-ecs-agent/agent/api/container" apieni "github.com/aws/amazon-ecs-agent/agent/api/eni" apitask "github.com/aws/amazon-ecs-agent/agent/api/task" apitaskstatus "github.com/aws/amazon-ecs-agent/agent/api/task/status" + docker "github.com/fsouza/go-dockerclient" "github.com/stretchr/testify/assert" ) @@ -31,71 +32,88 @@ const ( containerID = "cid" containerName = "sleepy" eniIPv4Address = "10.0.0.2" + volName = "volume1" + volSource = "/var/lib/volume1" + volDestination = "/volume" ) func TestTaskResponse(t *testing.T) { expectedTaskResponseMap := map[string]interface{}{ - "Arn": "t1", + "Arn": "t1", "DesiredStatus": "RUNNING", - "KnownStatus": "RUNNING", - "Family": "sleep", - "Version": "1", + "KnownStatus": "RUNNING", + "Family": "sleep", + "Version": "1", "Containers": []interface{}{ map[string]interface{}{ - "DockerId": "cid", + "DockerId": "cid", "DockerName": "sleepy", - "Name": "sleepy", + "Name": "sleepy", "Ports": []interface{}{ map[string]interface{}{ // The number should be float here, because when we unmarshal // something and we don't specify the number type, it will be // set to float. "ContainerPort": float64(80), - "Protocol": "tcp", - "HostPort": float64(80), + "Protocol": "tcp", + "HostPort": float64(80), }, }, "Networks": []interface{}{ map[string]interface{}{ - "NetworkMode": "awsvpc", + "NetworkMode": "awsvpc", "IPv4Addresses": []interface{}{"10.0.0.2"}, }, }, + "Volumes": []interface{}{ + map[string]interface{}{ + "DockerName": volName, + "Source": volSource, + "Destination": volDestination, + }, + }, }, }, } task := &apitask.Task{ - Arn: taskARN, - Family: family, - Version: version, - DesiredStatusUnsafe: apitaskstatus.TaskRunning, - KnownStatusUnsafe: apitaskstatus.TaskRunning, - ENI: &apieni.ENI{ - IPV4Addresses: []*apieni.ENIIPV4Address{ - { - Address: eniIPv4Address, - }, - }, - }, + Arn: taskARN, + Family: family, + Version: version, + DesiredStatusUnsafe: apitaskstatus.TaskRunning, + KnownStatusUnsafe: apitaskstatus.TaskRunning, + ENI: &apieni.ENI{ + IPV4Addresses: []*apieni.ENIIPV4Address{ + { + Address: eniIPv4Address, + }, + }, + }, } container := &apicontainer.Container{ - Name: containerName, - Ports: []apicontainer.PortBinding{ - { - ContainerPort: 80, - Protocol: apicontainer.TransportProtocolTCP, - }, - }, + Name: containerName, + Ports: []apicontainer.PortBinding{ + { + ContainerPort: 80, + Protocol: apicontainer.TransportProtocolTCP, + }, + }, + VolumesUnsafe: []docker.Mount{ + { + Name: volName, + Source: volSource, + Destination: volDestination, + }, + }, } containerNameToDockerContainer := map[string]*apicontainer.DockerContainer{ - taskARN: &apicontainer.DockerContainer{ - DockerID: containerID, - DockerName: containerName, - Container: container, - }, + taskARN: &apicontainer.DockerContainer{ + DockerID: containerID, + DockerName: containerName, + Container: container, + }, } taskResponse := NewTaskResponse(task, containerNameToDockerContainer) @@ -112,38 +130,52 @@ func TestTaskResponse(t *testing.T) { func TestContainerResponse(t *testing.T) { expectedContainerResponseMap := map[string]interface{}{ - "DockerId": "cid", + "DockerId": "cid", "DockerName": "sleepy", - "Name": "sleepy", + "Name": "sleepy", "Ports": []interface{}{ map[string]interface{}{ "ContainerPort": float64(80), - "Protocol": "tcp", - "HostPort": float64(80), + "Protocol": "tcp", + "HostPort": float64(80), }, }, "Networks": []interface{}{ map[string]interface{}{ - "NetworkMode": "awsvpc", + "NetworkMode": "awsvpc", "IPv4Addresses": []interface{}{"10.0.0.2"}, }, }, + "Volumes": []interface{}{ + map[string]interface{}{ + "DockerName": volName, + "Source": volSource, + "Destination": volDestination, + }, + }, } container := &apicontainer.Container{ - Name: containerName, - Ports: []apicontainer.PortBinding{ - { - ContainerPort: 80, - Protocol: apicontainer.TransportProtocolTCP, - }, - }, + Name: containerName, + Ports: []apicontainer.PortBinding{ + { + ContainerPort: 80, + Protocol: apicontainer.TransportProtocolTCP, + }, + }, + VolumesUnsafe: []docker.Mount{ + { + Name: volName, + Source: volSource, + Destination: volDestination, + }, + }, } dockerContainer := &apicontainer.DockerContainer{ - DockerID: containerID, - DockerName: containerName, - Container: container, + DockerID: containerID, + DockerName: containerName, + Container: container, } eni := &apieni.ENI{ @@ -179,7 +211,7 @@ func TestPortBindingsResponse(t *testing.T) { } dockerContainer := &apicontainer.DockerContainer{ - Container: container, + Container: container, } PortBindingsResponse := NewPortBindingsResponse(dockerContainer, nil) @@ -188,3 +220,26 @@ func TestPortBindingsResponse(t *testing.T) { assert.Equal(t, uint16(80), PortBindingsResponse[0].HostPort) assert.Equal(t, "tcp", PortBindingsResponse[0].Protocol) } + +func TestVolumesResponse(t *testing.T) { + container := &apicontainer.Container{ + Name: containerName, + VolumesUnsafe: []docker.Mount{ + { + Name: volName, + Source: volSource, + Destination: volDestination, + }, + }, + } + + dockerContainer := &apicontainer.DockerContainer{ + Container: container, + } + + VolumesResponse := NewVolumesResponse(dockerContainer) + + assert.Equal(t, volName, VolumesResponse[0].DockerName) + assert.Equal(t, volSource, VolumesResponse[0].Source) + assert.Equal(t, volDestination, VolumesResponse[0].Destination) +} diff --git a/agent/handlers/v2/response.go b/agent/handlers/v2/response.go index bfe18abc71c..12a3eedb9bf 100644 --- a/agent/handlers/v2/response.go +++ b/agent/handlers/v2/response.go @@ -62,6 +62,7 @@ type ContainerResponse struct { Type string `json:"Type"` Networks []containermetadata.Network `json:"Networks,omitempty"` Health *apicontainer.HealthStatus `json:"Health,omitempty"` + Volumes []v1.VolumeResponse `json:"Volumes,omitempty"` } // LimitsResponse defines the schema for task/cpu limits response @@ -208,5 +209,6 @@ func newContainerResponse(dockerContainer *apicontainer.DockerContainer, } } + resp.Volumes = v1.NewVolumesResponse(dockerContainer) return resp } diff --git a/agent/handlers/v2/response_test.go b/agent/handlers/v2/response_test.go index 1d777be9371..a0bf6ea1b63 100644 --- a/agent/handlers/v2/response_test.go +++ b/agent/handlers/v2/response_test.go @@ -28,6 +28,7 @@ import ( apitaskstatus "github.com/aws/amazon-ecs-agent/agent/api/task/status" "github.com/aws/amazon-ecs-agent/agent/engine/dockerstate/mocks" "github.com/aws/aws-sdk-go/aws" + docker "github.com/fsouza/go-dockerclient" "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" ) @@ -44,6 +45,9 @@ const ( cpu = 1024 memory = 512 eniIPv4Address = "10.0.0.2" + volName = "volume1" + volSource = "/var/lib/volume1" + volDestination = "/volume" ) func TestTaskResponse(t *testing.T) { @@ -86,6 +90,13 @@ func TestTaskResponse(t *testing.T) { Protocol: apicontainer.TransportProtocolTCP, }, }, + VolumesUnsafe: []docker.Mount{ + { + Name: volName, + Source: volSource, + Destination: volDestination, + }, + }, } created := time.Now() container.SetCreatedAt(created) @@ -154,6 +165,13 @@ func TestContainerResponse(t *testing.T) { Protocol: apicontainer.TransportProtocolTCP, }, }, + VolumesUnsafe: []docker.Mount{ + { + Name: volName, + Source: volSource, + Destination: volDestination, + }, + }, } created := time.Now() container.SetCreatedAt(created) From 9841777f1d18d1ccc8c25da9744aa7a47c62085a Mon Sep 17 00:00:00 2001 From: Sharanya Devaraj Date: Tue, 21 Aug 2018 16:57:21 +0000 Subject: [PATCH 2/5] Omit Volumes field in container JSON --- agent/api/container/container.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agent/api/container/container.go b/agent/api/container/container.go index f576ed8925e..819305aa13e 100644 --- a/agent/api/container/container.go +++ b/agent/api/container/container.go @@ -191,7 +191,7 @@ type Container struct { KnownPortBindingsUnsafe []PortBinding `json:"KnownPortBindings"` // VolumesUnsafe is an array of volume mounts in the container. - VolumesUnsafe []docker.Mount + VolumesUnsafe []docker.Mount `json:"-"` // SteadyStateStatusUnsafe specifies the steady state status for the container // If uninitialized, it's assumed to be set to 'ContainerRunning'. Even though From b5f0d095bea8532db16c7a73f9f8ae70967b61cb Mon Sep 17 00:00:00 2001 From: Sharanya Devaraj Date: Tue, 21 Aug 2018 17:19:41 +0000 Subject: [PATCH 3/5] added changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f61ded8f88c..9e5a309921f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog ## 1.20.2-dev +* Enhancement - Added Volumes metadata as part of v1 and v2 metadata endpoints [#1531](https://github.com/aws/amazon-ecs-agent/pull/1531) * Bug - Fixed a bug where unrecognized task cannot be stopped [#1467](https://github.com/aws/amazon-ecs-agent/pull/1467) * Enhancement - Added ECS config field to provide optionally comparing shared volumes' full details (driver options and labels), or names only [#1519](https://github.com/aws/amazon-ecs-agent/pull/1519) From 858b13d229d2052354a2916eef5bd612f93a337a Mon Sep 17 00:00:00 2001 From: Sharanya Devaraj Date: Tue, 21 Aug 2018 19:56:03 +0000 Subject: [PATCH 4/5] functional tests for volume metadata in introspection endpoints --- .../task-definition.json | 19 +++++++++++++-- .../task-definition.json | 19 +++++++++++++-- .../tests/functionaltests_unix_test.go | 4 ++-- .../agent-introspection-validator.go | 24 ++++++++++++++----- .../taskmetadata-validator.go | 17 +++++++++++-- 5 files changed, 69 insertions(+), 14 deletions(-) diff --git a/agent/functional_tests/testdata/taskdefinitions/agent-introspection-validator/task-definition.json b/agent/functional_tests/testdata/taskdefinitions/agent-introspection-validator/task-definition.json index a5a989e2e61..6650879593a 100644 --- a/agent/functional_tests/testdata/taskdefinitions/agent-introspection-validator/task-definition.json +++ b/agent/functional_tests/testdata/taskdefinitions/agent-introspection-validator/task-definition.json @@ -12,6 +12,21 @@ "awslogs-region":"$$$TEST_REGION$$$", "awslogs-stream-prefix":"ecs-functional-tests-agent-introspection-validator" } - } - }] + }, + "mountPoints": [ + { + "sourceVolume": "task-local", + "containerPath": "/ecs/" + } + ] + }], + "volumes":[ + { + "name": "task-local", + "dockerVolumeConfiguration" :{ + "scope": "task", + "driver": "local" + } + } + ] } diff --git a/agent/functional_tests/testdata/taskdefinitions/taskmetadata-validator-awsvpc/task-definition.json b/agent/functional_tests/testdata/taskdefinitions/taskmetadata-validator-awsvpc/task-definition.json index 2d3162dbbc9..ce0cd9aa760 100644 --- a/agent/functional_tests/testdata/taskdefinitions/taskmetadata-validator-awsvpc/task-definition.json +++ b/agent/functional_tests/testdata/taskdefinitions/taskmetadata-validator-awsvpc/task-definition.json @@ -19,6 +19,21 @@ "awslogs-region":"$$$TEST_REGION$$$", "awslogs-stream-prefix":"ecs-functional-tests-taskmetadata-validator" } - } - }] + }, + "mountPoints": [ + { + "sourceVolume": "task-local", + "containerPath": "/ecs/" + } + ] + }], + "volumes":[ + { + "name": "task-local", + "dockerVolumeConfiguration" :{ + "scope": "task", + "driver": "local" + } + } + ] } diff --git a/agent/functional_tests/tests/functionaltests_unix_test.go b/agent/functional_tests/tests/functionaltests_unix_test.go index 28a3807c79b..6b25e7f6eac 100644 --- a/agent/functional_tests/tests/functionaltests_unix_test.go +++ b/agent/functional_tests/tests/functionaltests_unix_test.go @@ -627,7 +627,7 @@ func TestAgentIntrospectionValidator(t *testing.T) { defer agent.Cleanup() // The Agent version was 1.14.2 when we added changes to agent introspection // endpoint feature for the last time. - agent.RequireVersion(">1.14.1") + agent.RequireVersion(">1.20.1") tdOverrides := make(map[string]string) tdOverrides["$$$TEST_REGION$$$"] = *ECS.Config.Region @@ -663,7 +663,7 @@ func TestTaskMetadataValidator(t *testing.T) { }, }) defer agent.Cleanup() - agent.RequireVersion(">1.16.2") + agent.RequireVersion(">1.20.1") tdOverrides := make(map[string]string) tdOverrides["$$$TEST_REGION$$$"] = *ECS.Config.Region diff --git a/misc/agent-introspection-validator/agent-introspection-validator.go b/misc/agent-introspection-validator/agent-introspection-validator.go index 9662d1dda97..ccf35f80e3d 100644 --- a/misc/agent-introspection-validator/agent-introspection-validator.go +++ b/misc/agent-introspection-validator/agent-introspection-validator.go @@ -50,11 +50,12 @@ type TasksResponse struct { // ContainerResponse is the schema for the container response JSON object type ContainerResponse struct { - DockerID string `json:"DockerId"` - DockerName string `json:"DockerName"` - Name string `json:"Name"` - Ports []PortResponse `json:"Ports,omitempty"` - Networks Network `json:"Networks,omitempty"` + DockerID string `json:"DockerId"` + DockerName string `json:"DockerName"` + Name string `json:"Name"` + Ports []PortResponse `json:"Ports,omitempty"` + Networks Network `json:"Networks,omitempty"` + Volumes []VolumeResponse `json:"Volumes,omitempty"` } // PortResponse defines the schema for portmapping response JSON @@ -72,6 +73,13 @@ type Network struct { IPv6Addresses []string `json:"IPv6Addresses,omitempty"` } +// VolumeResponse is the schema for the volume response JSON object +type VolumeResponse struct { + DockerName string `json:"DockerName,omitempty"` + Source string `json:"Source,omitempty"` + Destination string `json:"Destination,omitempty"` +} + func getTasksMetadata(client *http.Client, path string) (*TasksResponse, error) { body, err := metadataResponse(client, path, tasksMetadataRespType) if err != nil { @@ -188,7 +196,7 @@ func verifyContainerMetadata(containerMetadataRawMsg json.RawMessage) error { } var actualContainerName string - json.Unmarshal(containerMetadataMap["Name"] ,&actualContainerName) + json.Unmarshal(containerMetadataMap["Name"], &actualContainerName) if actualContainerName != containerName { return fmt.Errorf("incorrect container name, expected %s, received %s", @@ -203,6 +211,10 @@ func verifyContainerMetadata(containerMetadataRawMsg json.RawMessage) error { return notEmptyErrMsg("DockerName") } + if containerMetadataMap["Volumes"] == nil { + return notEmptyErrMsg("Volumes") + } + return nil } diff --git a/misc/taskmetadata-validator/taskmetadata-validator.go b/misc/taskmetadata-validator/taskmetadata-validator.go index 3198d6cc824..962eb195b18 100644 --- a/misc/taskmetadata-validator/taskmetadata-validator.go +++ b/misc/taskmetadata-validator/taskmetadata-validator.go @@ -61,8 +61,9 @@ type ContainerResponse struct { StartedAt *time.Time `json:",omitempty"` FinishedAt *time.Time `json:",omitempty"` Type string - Health HealthStatus `json:"health,omitempty"` - Networks []Network `json:",omitempty"` + Health HealthStatus `json:"health,omitempty"` + Networks []Network `json:",omitempty"` + Volumes []VolumeResponse `json:"Volumes,omitempty"` } type HealthStatus struct { @@ -94,6 +95,13 @@ type Network struct { IPv6Addresses []string `json:"IPv6Addresses,omitempty"` } +// VolumeResponse is the schema for the volume response JSON object +type VolumeResponse struct { + DockerName string `json:"DockerName,omitempty"` + Source string `json:"Source,omitempty"` + Destination string `json:"Destination,omitempty"` +} + func taskMetadata(client *http.Client) (*TaskResponse, error) { body, err := metadataResponse(client, v2MetadataEndpoint, "task metadata") if err != nil { @@ -243,6 +251,11 @@ func main() { } } + if containerMetadata.Volumes == nil { + fmt.Fprintf(os.Stderr, "Expected container volume metadata to be non-empty") + os.Exit(1) + } + _, err = taskStats(client) if err != nil { fmt.Fprintf(os.Stderr, "Unable to get task stats: %v", err) From 787e4148d1a6893d5a4e2fc9f485933b917f6c9a Mon Sep 17 00:00:00 2001 From: Sharanya Devaraj Date: Tue, 21 Aug 2018 23:35:57 +0000 Subject: [PATCH 5/5] address comments --- agent/engine/docker_task_engine_test.go | 9 +++++++++ .../taskmetadata-validator-awsvpc/task-definition.json | 7 ++++--- .../functional_tests/tests/functionaltests_unix_test.go | 2 -- agent/handlers/v1/response.go | 2 +- misc/taskmetadata-validator/taskmetadata-validator.go | 5 +++++ 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/agent/engine/docker_task_engine_test.go b/agent/engine/docker_task_engine_test.go index 049793cfcf9..d994ef361e1 100644 --- a/agent/engine/docker_task_engine_test.go +++ b/agent/engine/docker_task_engine_test.go @@ -1935,6 +1935,13 @@ func TestSynchronizeContainerStatus(t *testing.T) { labels := map[string]string{ "name": "metadata", } + volumes := []docker.Mount{ + { + Name: "volume", + Source: "/src/vol", + Destination: "/vol", + }, + } created := time.Now() gomock.InOrder( client.EXPECT().DescribeContainer(gomock.Any(), dockerID).Return(apicontainerstatus.ContainerRunning, @@ -1942,12 +1949,14 @@ func TestSynchronizeContainerStatus(t *testing.T) { Labels: labels, DockerID: dockerID, CreatedAt: created, + Volumes: volumes, }), imageManager.EXPECT().RecordContainerReference(dockerContainer.Container), ) taskEngine.(*DockerTaskEngine).synchronizeContainerStatus(dockerContainer, nil) assert.Equal(t, created, dockerContainer.Container.GetCreatedAt()) assert.Equal(t, labels, dockerContainer.Container.GetLabels()) + assert.Equal(t, volumes, dockerContainer.Container.GetVolumes()) } // TestHandleDockerHealthEvent tests the docker health event will only cause the diff --git a/agent/functional_tests/testdata/taskdefinitions/taskmetadata-validator-awsvpc/task-definition.json b/agent/functional_tests/testdata/taskdefinitions/taskmetadata-validator-awsvpc/task-definition.json index ce0cd9aa760..59f1993aceb 100644 --- a/agent/functional_tests/testdata/taskdefinitions/taskmetadata-validator-awsvpc/task-definition.json +++ b/agent/functional_tests/testdata/taskdefinitions/taskmetadata-validator-awsvpc/task-definition.json @@ -22,16 +22,17 @@ }, "mountPoints": [ { - "sourceVolume": "task-local", + "sourceVolume": "shared-local", "containerPath": "/ecs/" } ] }], "volumes":[ { - "name": "task-local", + "name": "shared-local", "dockerVolumeConfiguration" :{ - "scope": "task", + "scope": "shared", + "autoprovision":true, "driver": "local" } } diff --git a/agent/functional_tests/tests/functionaltests_unix_test.go b/agent/functional_tests/tests/functionaltests_unix_test.go index 6b25e7f6eac..c9d8f056b5b 100644 --- a/agent/functional_tests/tests/functionaltests_unix_test.go +++ b/agent/functional_tests/tests/functionaltests_unix_test.go @@ -625,8 +625,6 @@ func TestAgentIntrospectionValidator(t *testing.T) { }, }) defer agent.Cleanup() - // The Agent version was 1.14.2 when we added changes to agent introspection - // endpoint feature for the last time. agent.RequireVersion(">1.20.1") tdOverrides := make(map[string]string) diff --git a/agent/handlers/v1/response.go b/agent/handlers/v1/response.go index 05da93d586d..f26a6d6bf0b 100644 --- a/agent/handlers/v1/response.go +++ b/agent/handlers/v1/response.go @@ -156,7 +156,7 @@ func NewPortBindingsResponse(dockerContainer *apicontainer.DockerContainer, eni // NewVolumesResponse creates VolumeResponse for a container func NewVolumesResponse(dockerContainer *apicontainer.DockerContainer) []VolumeResponse { container := dockerContainer.Container - resp := []VolumeResponse{} + var resp []VolumeResponse volumes := container.GetVolumes() diff --git a/misc/taskmetadata-validator/taskmetadata-validator.go b/misc/taskmetadata-validator/taskmetadata-validator.go index 962eb195b18..4cf39ddb2e1 100644 --- a/misc/taskmetadata-validator/taskmetadata-validator.go +++ b/misc/taskmetadata-validator/taskmetadata-validator.go @@ -256,6 +256,11 @@ func main() { os.Exit(1) } + if containerMetadata.Volumes[0].DockerName != "shared-local" || containerMetadata.Volumes[0].Destination != "/ecs" { + fmt.Fprintf(os.Stderr, "Volume metadata fields incorrect") + os.Exit(1) + } + _, err = taskStats(client) if err != nil { fmt.Fprintf(os.Stderr, "Unable to get task stats: %v", err)