From e16fb19bfc5e0a098a7d5dc7f9bcbc1fd3e51dd3 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Wed, 2 Oct 2019 14:06:30 -0700 Subject: [PATCH] don't abort on a single error if another availability zone was able to create the instance --- .../amazon/common/step_run_spot_instance.go | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/builder/amazon/common/step_run_spot_instance.go b/builder/amazon/common/step_run_spot_instance.go index ab15bdff3..d8b1118cd 100644 --- a/builder/amazon/common/step_run_spot_instance.go +++ b/builder/amazon/common/step_run_spot_instance.go @@ -274,15 +274,20 @@ func (s *StepRunSpotInstance) Run(ctx context.Context, state multistep.StateBag) return multistep.ActionHalt } - if len(createOutput.Errors) > 0 { - errString := fmt.Sprintf("Error waiting for fleet request (%s) to become ready:", *createOutput.FleetId) - for _, outErr := range createOutput.Errors { - errString = errString + fmt.Sprintf("%s", *outErr.ErrorMessage) + if len(createOutput.Instances) == 0 { + // We can end up with errors because one of the allowed availability + // zones doesn't have one of the allowed instance types; as long as + // an instance is launched, these errors aren't important. + if len(createOutput.Errors) > 0 { + errString := fmt.Sprintf("Error waiting for fleet request (%s) to become ready:", *createOutput.FleetId) + for _, outErr := range createOutput.Errors { + errString = errString + fmt.Sprintf("%s", *outErr.ErrorMessage) + } + err = fmt.Errorf(errString) + state.Put("error", err) + ui.Error(err.Error()) + return multistep.ActionHalt } - err = fmt.Errorf(errString) - state.Put("error", err) - ui.Error(err.Error()) - return multistep.ActionHalt } instanceId = *createOutput.Instances[0].InstanceIds[0]