-
Notifications
You must be signed in to change notification settings - Fork 613
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 Private Host IPv4 address to container metadata #2000
Conversation
3a3ce18
to
e2918c2
Compare
e2918c2
to
8cc3d10
Compare
@bencord0 Could you please rebase from dev and update this PR? some test related fixes were made after this PR was open, and that should fix the failing windows functional test. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changes looks fine to me. were the *_mock.go changes generated with make gogenerate
?
thanks for the thorough testing with a dev build of the agent 🙏
_, _, _, _, done := managerSetup(t) | ||
defer done() | ||
newManager := &metadataManager{} | ||
newManager.SetHostPrivateIPv4Address(hostPublicIPv4Address) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: i think you meant to put hostPrivateIPv4Address
. looks like the assert statement just works cause the values are the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
_, _, _, _, done := managerSetup(t) | ||
defer done() | ||
newManager := &metadataManager{} | ||
newManager.SetHostPrivateIPv4Address(hostPublicIPv4Address) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
Related issue: aws#1575 Related PR: aws#1730 PR 1730 adds the Public IP Address of the host to the container metadata file, however the EC2 host may be configured without a public address. In this case, the EC2 metadata API returns a 404 response, and the host IP is not available to containers. Example ECS Agent Log ``` [ERROR] Unable to retrieve Host Instance PublicIPv4 Address: EC2MetadataError: failed to make EC2Metadata request caused by: <?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>404 - Not Found</title> </head> <body> <h1>404 - Not Found</h1> </body> </html> ``` This commit adds an extra field to the container metadata json, `HostPrivateIPv4Address` which is available on EC2 hosts without a public address.
8cc3d10
to
58da9df
Compare
@yunhee-l I've now rebased ontop of latest @adnxn I had trouble running the Also, typo in |
This requires another rebase on dev branch to push. I'm looking into pulling this PR myself, will update. |
#2025 opened, pulling from this PR. Closing this in favor of the new PR. |
Summary
Related issue: #1575
Related PR: #1730
PR 1730 adds the Public IP Address of the host to the container metadata
file, however the EC2 host may be configured without a public address.
In this case, the EC2 metadata API returns a 404 response, and the host
IP is not available to containers.
Example ECS Agent Log
This commit adds an extra field to the container metadata json,
HostPrivateIPv4Address
which is available on EC2 hosts withouta public address.
Implementation details
This commit mostly follows the implementation from #1730 but adds an extra field for the private IP. If the address is not available in the ec2 metadata, then the field is omitted in the container metadata json.
Testing
I've added tests for this field. Mostly they are copies of the existing public IP tests, with sed replacements.
I have also tested this with a running ECS instance based on Amazon Linux 2.
New tests cover the changes: yes
Description for the changelog
Feature - Add Host EC2 instance Private IPv4 address to container metadata file
Licensing
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.