@@ -486,6 +486,7 @@ func (env *azureEnviron) StartInstance(ctx context.ProviderCallContext, args env
486
486
if err != nil {
487
487
return nil , errors .Trace (err )
488
488
}
489
+ preferGen1Image := false
489
490
for i := 0 ; i < 15 ; i ++ {
490
491
// Identify the instance type and image to provision.
491
492
instanceSpec , err := env .findInstanceSpec (
@@ -497,7 +498,7 @@ func (env *azureEnviron) StartInstance(ctx context.ProviderCallContext, args env
497
498
Arch : arch ,
498
499
Constraints : args .Constraints ,
499
500
},
500
- imageStream ,
501
+ imageStream , preferGen1Image ,
501
502
)
502
503
if err != nil {
503
504
return nil , err
@@ -515,10 +516,18 @@ func (env *azureEnviron) StartInstance(ctx context.ProviderCallContext, args env
515
516
deleteInstanceFamily (instanceTypes , instanceSpec .InstanceType .Name )
516
517
continue
517
518
}
519
+ hypervisorGenErr , ok := errorutils .MaybeHypervisorGenNotSupportedError (err )
520
+ if ok && ! preferGen1Image {
521
+ logger .Warningf ("hypervisor generation 2 not supported for %q error: %q" , instanceSpec .InstanceType .Name , hypervisorGenErr .Error ())
522
+ logger .Warningf ("retrying with generation 1 image" )
523
+ preferGen1Image = true
524
+ continue
525
+ }
518
526
return result , errorutils .SimpleError (err )
519
527
}
520
528
return nil , errors .New ("no suitable instance type found for this subscription" )
521
529
}
530
+
522
531
func (env * azureEnviron ) startInstance (
523
532
ctx context.ProviderCallContext , args environs.StartInstanceParams ,
524
533
instanceSpec * instances.InstanceSpec , envTags map [string ]string ,
0 commit comments