From 1f3b3f8fd99bc029bebe073c8d0d4115e61334a9 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Tue, 21 Jul 2020 15:55:39 -0700 Subject: [PATCH] change retry func to a 15 min timeout --- builder/amazon/ebs/step_create_ami.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/builder/amazon/ebs/step_create_ami.go b/builder/amazon/ebs/step_create_ami.go index 22bb2f5ed..799737617 100644 --- a/builder/amazon/ebs/step_create_ami.go +++ b/builder/amazon/ebs/step_create_ami.go @@ -53,8 +53,12 @@ func (s *stepCreateAMI) Run(ctx context.Context, state multistep.StateBag) multi var createResp *ec2.CreateImageOutput var err error + // Create a timeout for the CreateImage call. + timeoutCtx, cancel := context.WithTimeout(ctx, time.Minute*15) + defer cancel() + err = retry.Config{ - Tries: 11, + Tries: 0, ShouldRetry: func(err error) bool { if awscommon.IsAWSErr(err, "InvalidParameterValue", "Instance is not in state") { return true @@ -62,7 +66,7 @@ func (s *stepCreateAMI) Run(ctx context.Context, state multistep.StateBag) multi return false }, RetryDelay: (&retry.Backoff{InitialBackoff: 200 * time.Millisecond, MaxBackoff: 30 * time.Second, Multiplier: 2}).Linear, - }.Run(ctx, func(ctx context.Context) error { + }.Run(timeoutCtx, func(ctx context.Context) error { createResp, err = ec2conn.CreateImage(createOpts) return err })