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

Use SDK's InstanceReady waiter #5773

Merged
merged 1 commit into from Jan 11, 2018
Merged

Use SDK's InstanceReady waiter #5773

merged 1 commit into from Jan 11, 2018

Conversation

mwhooker
Copy link
Contributor

@mwhooker mwhooker commented Jan 8, 2018

Closes #5705

This replaces our home grown instance ready waiter with the one from the SDK. This brings build times back to where they were in the previous release, but without the errors.

I cannot for the life of me reproduce the error with this patch, but since the error isn't falsifiable, it's going to be hard to tell if this fixes it completely. I'll keep running builds in a loop and see if I see any problems, but I think we'll probably be good with this patch


func waitUntilInstanceReady(ec2conn *ec2.EC2, instanceID, instanceType string) error {
statusOKMap := make(map[string]struct{})
statusOKMap["c5"] = struct{}{}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should have a comment explaining why this convoluted extra code for c5. something like // c5 instances need us to use the time-sucking WaitUntilStatusOK feature instead of just waiting for SSH to become available

Choose a reason for hiding this comment

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

Pretty sure the new m5 instance type is also backed by the new hypervisor. Ought to be easy to test if the issue is limited to c5, or if a more general approach is needed.

@SwampDragons
Copy link
Contributor

Apart from future-proofing the code with a small "why" comment, I think this is fine. I know you weren't a fan of special casing it, but it's probably the best way to go.

Copy link
Collaborator

@rickard-von-essen rickard-von-essen left a comment

Choose a reason for hiding this comment

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

I think it would be better to check if the virtualization type is the new KVM based type. I'm assuming all new instance types on that will be affected by this.

@@ -115,7 +115,6 @@ Packer to work:
"ec2:DeregisterImage",
"ec2:DescribeImageAttribute",
"ec2:DescribeImages",
"ec2:DescribeInstanceStatus",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Isn't this still needed for C5's?

@patrickf55places
Copy link

Why does the KVM hypervisor make the status check necessary? Why isn't SSH access enough?

@mwhooker
Copy link
Contributor Author

mwhooker commented Jan 10, 2018

@patrickf55places because the IP isn't available until some time after the InstanceReady check

@rickard-von-essen

I think it would be better to check if the virtualization type is the new KVM based type. I'm assuming all new instance types on that will be affected by this.

will investigate if that's feasible, but it sounds way better

@mwhooker
Copy link
Contributor Author

I've taken this in an odd direction. This replaces our home grown instance ready waiter with the one from the SDK. This brings build times back to where they were in the previous release, but without the errors.

I cannot for the life of me reproduce the error with this patch, but since the error isn't falsifiable, it's going to be hard to tell if this fixes it completely. I'll keep running builds in a loop and see if I see any problems, but I think we'll probably be good with this patch

@mwhooker
Copy link
Contributor Author

I very occasionally get ssh timeout errors, but I don't think these are related to discovering the public IP

~/dev/packertest ᐅ packer build -only 5627-ebs 5627.json
5627-ebs output will be in this color.

==> 5627-ebs: Prevalidating AMI Name: packer-qs-1515628931
    5627-ebs: Found Image ID: ami-cb9ec1b1
==> 5627-ebs: Creating temporary keypair: packer_5a56a983-6f58-dfe8-b7bf-4fdc80c15b14
==> 5627-ebs: Creating temporary security group for this instance: packer_5a56a98a-3c63-0cde-272a-4e72984db1fd
==> 5627-ebs: Authorizing access to port 22 from 0.0.0.0/0 in the temporary security group...
==> 5627-ebs: Launching a source AWS instance...
==> 5627-ebs: Adding tags to source instance
    5627-ebs: Adding tag: "Name": "Packer Builder"
    5627-ebs: Instance ID: i-0e105264a5b0995d1
==> 5627-ebs: Waiting for instance (i-0e105264a5b0995d1) to become ready...
    5627-ebs: Public DNS: ec2-54-147-134-244.compute-1.amazonaws.com
    5627-ebs: Public IP: 54.147.134.244
    5627-ebs: Private IP: 172.31.50.130
==> 5627-ebs: Waiting for SSH to become available...

==> 5627-ebs: Timeout waiting for SSH.
==> 5627-ebs: Terminating the source AWS instance...
==> 5627-ebs: Cleaning up any extra volumes...
==> 5627-ebs: Deleting temporary security group...
==> 5627-ebs: Deleting temporary keypair...
Build '5627-ebs' errored: Timeout waiting for SSH.

@mwhooker mwhooker changed the title Only use instance status when type is c5.x Use SDK's InstanceReady waiter Jan 11, 2018
Copy link
Contributor

@SwampDragons SwampDragons left a comment

Choose a reason for hiding this comment

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

Way better and simpler. Verified it works with both c5 instance types and older instance types.

@sparkcodeuk
Copy link

👍 had same issue with a t2.nano build, was missing "ec2:DescribeInstanceStatus" permission on packer IAM user

@mwhooker mwhooker deleted the fix5705 branch April 16, 2018 17:21
@ghost
Copy link

ghost commented Apr 1, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@hashicorp hashicorp locked and limited conversation to collaborators Apr 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Option to allow skipping of EC2 instance checks
6 participants