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

Add Host IP to port response for v2 container response #3112

Merged
merged 1 commit into from
Jan 4, 2022

Conversation

mythri-garaga
Copy link
Contributor

@mythri-garaga mythri-garaga commented Jan 3, 2022

Summary

Currently there is no way to identify ipv4 ports vs ipv6 ports from Task metadata endpoint v4. This PR includes changes to add Host IP to port response for Task metadata endpoint v2 onwards.

Related to issue - #3096

Implementation details

  • agent/handlers/v1/response.go : update PortResponse struct to include HostIp field.
  • agent/handlers/v2/response.go : add HostIp to container response and update tests accordingly.

Testing

Tested this change by running a task with container port mappings configured on a IPv6 enabled instance and see the following response for curl ${ECS_CONTAINER_METADATA_URI_V4}/task

{
  "Cluster": "default",
  ...
  "Containers": [
    {
      "DockerId": "be27aa9a7e8905edd8aea8cb17e428255dc365bd3f729ae02eeff0c6fd96aba6",
      "Name": "server",
      "DockerName": "ecs-nginx-server-3-server-f096d1ccbfb2bda87a00",      "Image": "nginx:latest",      "ImageID": "sha256:605c77e624ddb75e6110f997c58876baa13f8754486b461117934b24a9dc3a85",      "Ports": [        {
          "ContainerPort": 8888,
          "Protocol": "tcp",          
         "HostPort": 49825,          
         "HostIP": "0.0.0.0"        
         },        
        {          
      "ContainerPort": 8888,
          "Protocol": "tcp",
          "HostPort": 49825,
          "HostIP": "::"
        },
        {
          "ContainerPort": 8888,
          "Protocol": "tcp",
          "HostPort": 49832,          
         "HostIP": "0.0.0.0"
        },
        { 
         "ContainerPort": 8888,
          "Protocol": "tcp",
          "HostPort": 49832,
          "HostIP": "::"
        }
      ],
      ...
}

New tests cover the changes: yes

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.

@mythri-garaga mythri-garaga marked this pull request as ready for review January 3, 2022 23:24
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.

4 participants