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

Instance Running waiter not aware of global waiter settings #8699

Merged
merged 1 commit into from
Feb 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions builder/amazon/common/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,19 @@ func WaitUntilAMIAvailable(ctx aws.Context, conn ec2iface.EC2API, imageId string
return err
}

func WaitUntilInstanceRunning(ctx aws.Context, conn *ec2.EC2, instanceId string) error {

instanceInput := ec2.DescribeInstancesInput{
InstanceIds: []*string{&instanceId},
}

err := conn.WaitUntilInstanceRunningWithContext(
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh super nice, I wasn't aware of this one !

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice! Seeing as we don’t actually use err here we can just return with the call to conn.WaitUntilInstanceRunningWithContext(...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nywilken I'm following the convention of other existing WaitUntil* methods in state.go

Copy link
Contributor

Choose a reason for hiding this comment

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

@fly1028 thanks I only looked at the diff. But this is good to go I just have not had a chance to merge.

ctx,
&instanceInput,
getWaiterOptions()...)
return err
}

func WaitUntilInstanceTerminated(ctx aws.Context, conn *ec2.EC2, instanceId string) error {

instanceInput := ec2.DescribeInstancesInput{
Expand Down
3 changes: 2 additions & 1 deletion builder/amazon/common/step_run_source_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@ func (s *StepRunSourceInstance) Run(ctx context.Context, state multistep.StateBa
describeInstance := &ec2.DescribeInstancesInput{
InstanceIds: []*string{aws.String(instanceId)},
}
if err := ec2conn.WaitUntilInstanceRunningWithContext(ctx, describeInstance); err != nil {

if err := WaitUntilInstanceRunning(ctx, ec2conn, instanceId); err != nil {
err := fmt.Errorf("Error waiting for instance (%s) to become ready: %s", instanceId, err)
state.Put("error", err)
ui.Error(err.Error())
Expand Down