Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions pkg/installer/generateconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,21 +165,20 @@ func (m *manager) generateInstallConfig(ctx context.Context) (*installconfig.Ins
// from a manifest so it can be specified in the RP's
// OpenShiftClusterVersions?

imageSKU := "aro_420" // Gen1 SKU (default)
// 4.20 onwards, we default to Gen2 images
imageSKU := "aro_420-v2" // Gen2 SKU (default)

// Check if any SKU requires V2 only (doesn't support V1)
masterRequiresV2, err := determineSkuSupportsV2Only(masterSKU)
// If any SKU doesn't support V2, use Gen1 images
masterSupportsV2, err := determineV2SkuSupport(masterSKU)
if err != nil {
return nil, nil, errors.WithStack(err)
}
workerRequiresV2, err := determineSkuSupportsV2Only(workerSKU)
workerSupportsV2, err := determineV2SkuSupport(workerSKU)
if err != nil {
return nil, nil, errors.WithStack(err)
}

// If any SKU only supports V2, use Gen2 images for the entire cluster.
if masterRequiresV2 || workerRequiresV2 {
imageSKU = "aro_420-v2"
if !masterSupportsV2 || !workerSupportsV2 {
imageSKU = "aro_420"
}

rhcosImage := &azuretypes.OSImage{
Expand Down Expand Up @@ -475,9 +474,8 @@ func determineAvailabilityZones(controlPlaneSKU, workerSKU *mgmtcompute.Resource
return controlPlaneZones, workerZones, nil
}

// determineSkuSupportsV2Only checks if the SKU ONLY supports HyperV Generation V2 (not V1).
// Returns true if the SKU requires Gen2 images (supports V2 but not V1).
func determineSkuSupportsV2Only(sku *mgmtcompute.ResourceSku) (bool, error) {
// determineV2SkuSupport returns true if the SKU supports HyperV Generation V2
func determineV2SkuSupport(sku *mgmtcompute.ResourceSku) (bool, error) {
skuCapabilities, capabilityExists := computeskus.GetCapabilityMap(sku)
if !capabilityExists {
return false, fmt.Errorf("no capabilities found for SKU %s", *sku.Name)
Expand All @@ -486,5 +484,5 @@ func determineSkuSupportsV2Only(sku *mgmtcompute.ResourceSku) (bool, error) {
if err != nil {
return false, fmt.Errorf("could not fetch HyperV generations for SKU %s: %w", *sku.Name, err)
}
return generations.Has("V2") && !generations.Has("V1"), nil
return generations.Has("V2"), nil
}
12 changes: 6 additions & 6 deletions pkg/installer/generateconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,25 @@ func TestVMNetworkingType(t *testing.T) {
}
}

func TestDetermineSkuSupportsV2Only(t *testing.T) {
func TestDetermineV2SkuSupport(t *testing.T) {
for _, tt := range []struct {
name string
sku *mgmtcompute.ResourceSku
wantResult bool
wantErr string
}{
{
name: "sku supports both V1 and V2, does not require V2",
name: "sku supports both V1 and V2",
sku: &mgmtcompute.ResourceSku{
Name: to.StringPtr("Standard_D8s_v3"),
Capabilities: &[]mgmtcompute.ResourceSkuCapabilities{
{Name: to.StringPtr("HyperVGenerations"), Value: to.StringPtr("V1,V2")},
},
},
wantResult: false,
wantResult: true,
},
{
name: "sku supports only V2, requires V2",
name: "sku supports only V2",
sku: &mgmtcompute.ResourceSku{
Name: to.StringPtr("Standard_D8s_v6"),
Capabilities: &[]mgmtcompute.ResourceSkuCapabilities{
Expand All @@ -78,7 +78,7 @@ func TestDetermineSkuSupportsV2Only(t *testing.T) {
wantResult: true,
},
{
name: "sku supports only V1, does not require V2",
name: "sku supports only V1",
sku: &mgmtcompute.ResourceSku{
Name: to.StringPtr("Standard_D2_v2"),
Capabilities: &[]mgmtcompute.ResourceSkuCapabilities{
Expand Down Expand Up @@ -108,7 +108,7 @@ func TestDetermineSkuSupportsV2Only(t *testing.T) {
},
} {
t.Run(tt.name, func(t *testing.T) {
result, err := determineSkuSupportsV2Only(tt.sku)
result, err := determineV2SkuSupport(tt.sku)

if tt.wantErr != "" {
if err == nil {
Expand Down