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

app: use sdk awserr for imds #2243

Merged
merged 1 commit into from
Oct 21, 2019
Merged

app: use sdk awserr for imds #2243

merged 1 commit into from
Oct 21, 2019

Conversation

adnxn
Copy link
Contributor

@adnxn adnxn commented Oct 20, 2019

Summary

fixes #1857

this was an error handling miss when we moved from our custom imds client to the one provided by the sdk. previously we would return a custom error type and fail gracefully when the vpc-id could not be detected on ec2-classic. once we switched to the aws sdk, the imds client started returning EC2MetadataError for this failure mode and the func isInstanceLaunchedInVPC codepath would not detect the correct error type returned by the sdk.

Implementation details

Testing

manually tested, repro bug:

2019-10-21T18:07:30Z [INFO] Amazon ECS agent Version: 1.32.0, Commit: a7f81040
2019-10-21T18:07:30Z [INFO] Creating root ecs cgroup: /ecs
2019-10-21T18:07:30Z [INFO] Creating cgroup /ecs
2019-10-21T18:07:30Z [INFO] Loading state! module="statemanager"
2019-10-21T18:07:30Z [INFO] Event stream ContainerChange start listening...
2019-10-21T18:07:30Z [CRITICAL] Unable to initialize Task ENI dependencies: unable to get vpc id from instance metadata: 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>

manually tested, with fix:

2019-10-21T19:48:16Z [INFO] Amazon ECS agent Version: 1.32.0, Commit: 2b7afa8a
2019-10-21T19:48:16Z [INFO] Creating root ecs cgroup: /ecs
2019-10-21T19:48:16Z [INFO] Creating cgroup /ecs
2019-10-21T19:48:16Z [INFO] Loading state! module="statemanager"
2019-10-21T19:48:16Z [INFO] Event stream ContainerChange start listening...
2019-10-21T19:48:16Z [INFO] Restored cluster 'default'
2019-10-21T19:48:16Z [WARN] Unable to detect VPC ID for the Instance, disabling Task ENI capability: instance not launched in VPC
2019-10-21T19:48:16Z [INFO] Missing cpu flags for EIA support: avx2
2019-10-21T19:48:16Z [INFO] Restored from checkpoint file. I am running as 'arn:aws:ecs:us-east-1:410584942969:container-instance/a1f985bb-2d2d-487e-8687-e9600a3c8fa9' in cluster 'default'
2019-10-21T19:48:16Z [INFO] Remaining mem: 15031
2019-10-21T19:48:16Z [INFO] Registered container instance with cluster!
2019-10-21T19:48:16Z [INFO] Saving state! module="statemanager"
2019-10-21T19:48:16Z [INFO] Beginning Polling for updates
2019-10-21T19:48:16Z [INFO] Event stream DeregisterContainerInstance start listening...
2019-10-21T19:48:16Z [INFO] Initializing stats engine
2019-10-21T19:48:16Z [INFO] Establishing a Websocket connection to https://ecs-a-2.us-east-1.amazonaws.com/ws?agentHash=2b7afa8a&agentVersion=1.32.0&clusterArn=default&containerInstanceArn=arn%3Aaws%3Aecs%3Aus-east-1%3A410584942969%3Acontainer-instance%2Fa1f985bb-2d2d-487e-8687-e9600a3c8fa9&dockerVersion=DockerVersion%3A+18.06.1-ce&sendCredentials=true&seqNum=1
2019-10-21T19:48:16Z [INFO] NO_PROXY set:169.254.169.254,169.254.170.2,/var/run/docker.sock
2019-10-21T19:48:16Z [INFO] Establishing a Websocket connection to https://ecs-t-2.us-east-1.amazonaws.com/ws?agentHash=2b7afa8a&agentVersion=1.32.0&cluster=default&containerInstance=arn%3Aaws%3Aecs%3Aus-east-1%3A410584942969%3Acontainer-instance%2Fa1f985bb-2d2d-487e-8687-e9600a3c8fa9&dockerVersion=18.06.1-ce
2019-10-21T19:48:16Z [INFO] Connected to TCS endpoint
2019-10-21T19:48:16Z [INFO] Connected to ACS endpoint
2019-10-21T19:48:23Z [INFO] Saving state! module="statemanager"

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.

@adnxn adnxn changed the title [wip] app: use sdk awserr for imds app: use sdk awserr for imds Oct 21, 2019
@adnxn adnxn marked this pull request as ready for review October 21, 2019 17:08
Copy link
Contributor

@petderek petderek left a comment

Choose a reason for hiding this comment

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

lgtm

@adnxn adnxn merged commit 6125b11 into aws:dev Oct 21, 2019
@adnxn adnxn added this to the 1.33.0 milestone Oct 23, 2019
@shubham2892 shubham2892 modified the milestones: 1.33.0, 1.32.1 Oct 24, 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.

4 participants