Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3 metadata networks response for non-awsvpc tasks #1833

Merged
merged 2 commits into from
Feb 8, 2019

Conversation

sharanyad
Copy link
Contributor

@sharanyad sharanyad commented Feb 5, 2019

Summary

v3 metadata networks response for non-awsvpc tasks was empty. Add networks response for all modes.

Implementation details

adding network metadata to v2 task/container metadata responses

Testing

  • Builds on Linux (make release)
  • Builds on Windows (go build -out amazon-ecs-agent.exe ./agent)
  • Unit tests on Linux (make test) pass
  • Unit tests on Windows (go test -timeout=30s ./agent/...) pass
  • Integration tests on Linux (make run-integ-tests) pass
  • Integration tests on Windows (.\scripts\run-integ-tests.ps1) pass
  • Functional tests on Linux (make run-functional-tests) pass
  • Functional tests on Windows (.\scripts\run-functional-tests.ps1) pass

New tests cover the changes: yes

manual testing:

curl $ECS_CONTAINER_METADATA_URI | python -mjson.tool
{
    "CreatedAt": "2019-02-04T23:09:18.482622006Z",
    "DesiredStatus": "RUNNING",
    "DockerId": "c39b3407963ca852f3f905c2739458f4bfbf5a6daa39415637d725ef651bc94d",
    "DockerName": "ecs-sleep-5-busy-sleep-aacfbbedecb6f0cde801",
    "Image": "ubuntu",
    "ImageID": "sha256:20bb25d32758db4f91b18a9581794cfaa6a8c5fbad80093e9a9e42211e131a48",
    "KnownStatus": "RUNNING",
    "Labels": {
        "com.amazonaws.ecs.cluster": "default",
        "com.amazonaws.ecs.container-name": "busy-sleep",
        "com.amazonaws.ecs.task-arn": "arn:aws:ecs:us-west-2::task/b2f909df-43e5-4717-a8c6-99905475cd03",
        "com.amazonaws.ecs.task-definition-family": "sleep",
        "com.amazonaws.ecs.task-definition-version": "5"
    },
    "Limits": {
        "CPU": 512,
        "Memory": 100
    },
    "Name": "busy-sleep",
    "Networks": [
        {
            "IPv4Addresses": [
                "172.17.0.2"
            ],
            "NetworkMode": "default"
        }
    ],
    "StartedAt": "2019-02-04T23:09:19.00245409Z",
    "Type": "NORMAL"
}

curl $ECS_CONTAINER_METADATA_URI/task | python -mjson.tool
{
    "AvailabilityZone": "us-west-2a",
    "Cluster": "default",
    "Containers": [
        {
            "CreatedAt": "2019-02-04T23:09:18.482622006Z",
            "DesiredStatus": "RUNNING",
            "DockerId": "c39b3407963ca852f3f905c2739458f4bfbf5a6daa39415637d725ef651bc94d",
            "DockerName": "ecs-sleep-5-busy-sleep-aacfbbedecb6f0cde801",
            "Image": "ubuntu",
            "ImageID": "sha256:20bb25d32758db4f91b18a9581794cfaa6a8c5fbad80093e9a9e42211e131a48",
            "KnownStatus": "RUNNING",
            "Labels": {
                "com.amazonaws.ecs.cluster": "default",
                "com.amazonaws.ecs.container-name": "busy-sleep",
                "com.amazonaws.ecs.task-arn": "arn:aws:ecs:us-west-2::task/b2f909df-43e5-4717-a8c6-99905475cd03",
                "com.amazonaws.ecs.task-definition-family": "sleep",
                "com.amazonaws.ecs.task-definition-version": "5"
            },
            "Limits": {
                "CPU": 512,
                "Memory": 100
            },
            "Name": "busy-sleep",
            "Networks": [
                {
                    "IPv4Addresses": [
                        "172.17.0.2"
                    ],
                    "NetworkMode": "default"
                }
            ],
            "StartedAt": "2019-02-04T23:09:19.00245409Z",
            "Type": "NORMAL"
        }
    ],
    "DesiredStatus": "RUNNING",
    "Family": "sleep",
    "KnownStatus": "RUNNING",
    "PullStartedAt": "2019-02-04T23:09:15.072280841Z",
    "PullStoppedAt": "2019-02-04T23:09:18.475952428Z",
    "Revision": "5",
    "TaskARN": "arn:aws:ecs:us-west-2:074626758757:task/b2f909df-43e5-4717-a8c6-99905475cd03"
}

Description for the changelog

Licensing

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@sharanyad sharanyad changed the title [WIP] v3 metadata networks response for non-awsvpc tasks v3 metadata networks response for non-awsvpc tasks Feb 5, 2019
@sharanyad
Copy link
Contributor Author

looks like a windows integ test(flakey, haven't seen this one before) failed - TestVolumesFromRO


// GetContainerResponse gets container response for v3 metadata
func GetContainerResponse(containerID string, state dockerstate.TaskEngineState) (*v2.ContainerResponse, error) {
containerResponse, err := v2.NewContainerResponse(containerID, state)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for my understanding -

why aren't we keeping the logic to build up the responses in response.go where the rest of the structure is constructed? it's not obvious to me why we are appending this metadata a layer above.

same question for the task response structure.

Copy link
Contributor Author

@sharanyad sharanyad Feb 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the network information is populated in v2's response.go only if the task has an ENI, since it should work only for awsvpc tasks. So I added logic here to add network response for non awsvpc tasks. let me know if that makes sense

Copy link
Contributor

@adnxn adnxn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for explaining the reponse.go thing

Protocol: apicontainer.TransportProtocolTCP,
},
},
NetworkModeUnsafe: bridgeMode,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: did you run go fmt on this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did and doesn't report of anything different

@sharanyad sharanyad merged commit e9df282 into aws:dev Feb 8, 2019
@sharanyad sharanyad added this to the 1.25.3 milestone Feb 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants