From 8a40e7322d067148ed75d0e0d5dd6a674f03d79a Mon Sep 17 00:00:00 2001 From: Yadnesh Kulkarni Date: Tue, 20 Jan 2026 16:07:46 +0530 Subject: [PATCH] Default to Gen2 images for OpenShift 4.20+ with fallback to Gen1 From 4.20 onwards, clusters will be deployed with V2 images. If the selected SKU doesn't support it, then fallback to using V1 image. Fixes ARO-23073 Signed-off-by: Yadnesh Kulkarni --- pkg/installer/generateconfig.go | 22 ++++++++++------------ pkg/installer/generateconfig_test.go | 12 ++++++------ 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/pkg/installer/generateconfig.go b/pkg/installer/generateconfig.go index 757959b0a..b1c4b32e2 100644 --- a/pkg/installer/generateconfig.go +++ b/pkg/installer/generateconfig.go @@ -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{ @@ -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) @@ -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 } diff --git a/pkg/installer/generateconfig_test.go b/pkg/installer/generateconfig_test.go index 64cd6a5ca..47d33b135 100644 --- a/pkg/installer/generateconfig_test.go +++ b/pkg/installer/generateconfig_test.go @@ -50,7 +50,7 @@ func TestVMNetworkingType(t *testing.T) { } } -func TestDetermineSkuSupportsV2Only(t *testing.T) { +func TestDetermineV2SkuSupport(t *testing.T) { for _, tt := range []struct { name string sku *mgmtcompute.ResourceSku @@ -58,17 +58,17 @@ func TestDetermineSkuSupportsV2Only(t *testing.T) { 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{ @@ -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{ @@ -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 {