Skip to content

Commit 2a74f38

Browse files
authored
Merge pull request #18745 from anvial/backport-pr-18264
fix: backport azure image lookup fix
2 parents 84a680a + 916ad94 commit 2a74f38

File tree

7 files changed

+414
-151
lines changed

7 files changed

+414
-151
lines changed

provider/azure/environ.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,7 @@ func (env *azureEnviron) StartInstance(ctx context.ProviderCallContext, args env
486486
if err != nil {
487487
return nil, errors.Trace(err)
488488
}
489+
preferGen1Image := false
489490
for i := 0; i < 15; i++ {
490491
// Identify the instance type and image to provision.
491492
instanceSpec, err := env.findInstanceSpec(
@@ -497,7 +498,7 @@ func (env *azureEnviron) StartInstance(ctx context.ProviderCallContext, args env
497498
Arch: arch,
498499
Constraints: args.Constraints,
499500
},
500-
imageStream,
501+
imageStream, preferGen1Image,
501502
)
502503
if err != nil {
503504
return nil, err
@@ -515,10 +516,18 @@ func (env *azureEnviron) StartInstance(ctx context.ProviderCallContext, args env
515516
deleteInstanceFamily(instanceTypes, instanceSpec.InstanceType.Name)
516517
continue
517518
}
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+
}
518526
return result, errorutils.SimpleError(err)
519527
}
520528
return nil, errors.New("no suitable instance type found for this subscription")
521529
}
530+
522531
func (env *azureEnviron) startInstance(
523532
ctx context.ProviderCallContext, args environs.StartInstanceParams,
524533
instanceSpec *instances.InstanceSpec, envTags map[string]string,

0 commit comments

Comments
 (0)