Merge pull request #9480 from adongy/master

aws: retry fetching blockdevicemapping if empty
This commit is contained in:
Megan Marsh 2020-07-08 12:32:12 -07:00 committed by GitHub
commit 4d3b2cea96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -324,6 +324,11 @@ func (s *StepRunSpotInstance) Run(ctx context.Context, state multistep.StateBag)
describeOutput, err = ec2conn.DescribeInstances(&ec2.DescribeInstancesInput{
InstanceIds: []*string{aws.String(instanceId)},
})
if len(describeOutput.Reservations) > 0 && len(describeOutput.Reservations[0].Instances) > 0 {
if len(s.LaunchMappings.BuildEC2BlockDeviceMappings()) > 0 && len(describeOutput.Reservations[0].Instances[0].BlockDeviceMappings) == 0 {
return fmt.Errorf("Instance has no block devices")
}
}
return err
})
if err != nil || len(describeOutput.Reservations) == 0 || len(describeOutput.Reservations[0].Instances) == 0 {