This repository was archived by the owner on Jul 18, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -45,7 +45,8 @@ const (
4545)
4646
4747const (
48- keypairNotFoundCode = "InvalidKeyPair.NotFound"
48+ keypairNotFoundCode = "InvalidKeyPair.NotFound"
49+ spotInstanceRequestNotFoundCode = "InvalidSpotInstanceRequestID.NotFound"
4950)
5051
5152var (
@@ -640,11 +641,21 @@ func (d *Driver) Create() error {
640641 }
641642
642643 log .Info ("Waiting for spot instance..." )
643- err = d .getClient ().WaitUntilSpotInstanceRequestFulfilled (& ec2.DescribeSpotInstanceRequestsInput {
644- SpotInstanceRequestIds : []* string {spotInstanceRequest .SpotInstanceRequests [0 ].SpotInstanceRequestId },
645- })
646- if err != nil {
647- return fmt .Errorf ("Error fulfilling spot request: %v" , err )
644+ for i := 0 ; i < 3 ; i ++ {
645+ // AWS eventual consistency means we could not have SpotInstanceRequest ready yet
646+ err = d .getClient ().WaitUntilSpotInstanceRequestFulfilled (& ec2.DescribeSpotInstanceRequestsInput {
647+ SpotInstanceRequestIds : []* string {spotInstanceRequest .SpotInstanceRequests [0 ].SpotInstanceRequestId },
648+ })
649+ if err != nil {
650+ if awsErr , ok := err .(awserr.Error ); ok {
651+ if awsErr .Code () == spotInstanceRequestNotFoundCode {
652+ time .Sleep (5 * time .Second )
653+ continue
654+ }
655+ }
656+ return fmt .Errorf ("Error fulfilling spot request: %v" , err )
657+ }
658+ break
648659 }
649660 log .Info ("Created spot instance request %v" , * spotInstanceRequest .SpotInstanceRequests [0 ].SpotInstanceRequestId )
650661 // resolve instance id
You can’t perform that action at this time.
0 commit comments