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

ECS Container Metadata doesn't contain the actual Host port in cases where its dynamically assigned #1052

Closed
aldelucca1 opened this issue Nov 4, 2017 · 2 comments
Assignees
Milestone

Comments

@aldelucca1
Copy link

aldelucca1 commented Nov 4, 2017

Summary

When setting the environment variable:

ECS_ENABLE_CONTAINER_METADATA=true

The container metadata file is written to the filesystem as expected. When looking at the content of the file it appears as if the value of the Port Mappings are taken literally from the Task definition and don't actually reflect the running state of the container instance, in cases where HostPort is set to 0

Description

There are many instances where knowing the actual Host port the container is bound to from inside the container is helpful. Reading through the issues that are attached to the PR to enable this information seem to suggest that this case should be covered.

#288

Expected Behavior

The PortMapping section of the ECS Metadata would contain the actual port mapping in cases where 0 was used to dynamically assign a port on the host.

Observed Behavior

The Port Mapping section contains the literal value of 0

"PortMappings": [
	{
		"ContainerPort": 80,
		"HostPort": 0,
		"BindIp": "",
		"Protocol": "tcp"
	}
],

Environment Details

 Running: 3
 Paused: 0
 Stopped: 0
Images: 3
Server Version: 17.06.2-ce
Storage Driver: devicemapper
 Pool Name: docker-docker--pool
 Pool Blocksize: 524.3kB
 Base Device Size: 10.74GB
 Backing Filesystem: ext4
 Data file: 
 Metadata file: 
 Data Space Used: 995.6MB
 Data Space Total: 23.33GB
 Data Space Available: 22.33GB
 Metadata Space Used: 864.3kB
 Metadata Space Total: 25.17MB
 Metadata Space Available: 24.3MB
 Thin Pool Minimum Free Space: 2.333GB
 Udev Sync Supported: true
 Deferred Removal Enabled: true
 Deferred Deletion Enabled: true
 Deferred Deleted Device Count: 0
 Library Version: 1.02.135-RHEL7 (2016-11-16)
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins: 
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 6e23458c129b551d5c9871e5174f6b1b7f6d1170
runc version: 810190ceaa507aa2727d7ae6f4790c76ec150bd2
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.58-18.51.amzn1.x86_64
Operating System: Amazon Linux AMI 2017.09
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 7.798GiB
Name: ip-10-0-1-13
ID: I4JY:2OJB:PXCH:6CTQ:WLSC:MHKJ:H6SA:GIRK:JLAE:XQLE:UOSG:BFBU
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false
{"Cluster":"ecs-dado-cluster","ContainerInstanceArn":"arn:aws:ecs:us-east-2:994070776455:container-instance/e3d53687-f2e8-4199-88e5-1e6e0478c1af","Version":"Amazon ECS Agent - v1.15.0 (d2dd240)"}[root@ip-10-0-1-13 ec2-user]# 
/dev/xvda1      7.8G  746M  7.0G  10% /
devtmpfs        3.9G   92K  3.9G   1% /dev
tmpfs           3.9G     0  3.9G   0% /dev/shm
/dev/dm-3       9.8G   47M  9.2G   1% /var/lib/docker/devicemapper/mnt/532e2ae48f46ae7feb46f46e83c688155d113e6baf1bd87c08ef5bee0556d9d4
shm              64M     0   64M   0% /var/lib/docker/containers/b9623dc56f654c1beed0a2599d43ff333081a03ba5b8cc2bcd22eb75cd9eee61/shm
/dev/dm-4       9.8G  443M  8.8G   5% /var/lib/docker/devicemapper/mnt/9a454989d9da81f7cacbf27c079d34dccff527d4acdfb4209f671f48cb88ed7b
shm              64M     0   64M   0% /var/lib/docker/containers/aa03809b694c393032452fc09bbcb05f930987a6635c40109bfa766027bdd50b/shm
/dev/dm-5       9.8G  443M  8.8G   5% /var/lib/docker/devicemapper/mnt/68f93dc805628f1f308f1e1679516c40f78aa341e831b1cb511ec654bc675f91
shm              64M     0   64M   0% /var/lib/docker/containers/a0f3076cece39242975b72681f43d858d8ef8604a0bc5265ef5c06089507280e/shm

Supporting Log Snippets

@adamrothman
Copy link

Came here to post this exact issue – awesome to see that it's already being addressed. Thanks everyone!

@nmeyerhans
Copy link
Contributor

We've released agent version 1.15.1 including a fix for this issue. It's available on Docker Hub and in the 2017.09.b ECS Optmized AMI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants